Skip to content

Instantly share code, notes, and snippets.

@troyharris
Last active December 20, 2015 02:39
Show Gist options
  • Save troyharris/6057431 to your computer and use it in GitHub Desktop.
Save troyharris/6057431 to your computer and use it in GitHub Desktop.
Convert iPad fontSize to iPhone and Vice-Versa
#
# 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