Last active
December 20, 2015 02:39
-
-
Save troyharris/6057431 to your computer and use it in GitHub Desktop.
Convert iPad fontSize to iPhone and Vice-Versa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# As far as I can tell, iOS treats fontSize based on PPI. It's not completely perfect but here is a good ratio to use. | |
# Spoiler: It's 2.591 | |
# | |
+(CGFloat)getFontSizeFromIPadFontSize:(CGFloat)fontSize { | |
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { | |
fontSize = fontSize / 2.591; | |
} | |
return fontSize; | |
} | |
+(CGFloat)getFontSizeFromIPhoneFontSize:(CGFloat)fontSize { | |
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { | |
fontSize = fontSize * 2.591; | |
} | |
return fontSize; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment