Created
July 27, 2016 21:54
-
-
Save bdalziel/c83758961287aaec4bd2606a9e51d113 to your computer and use it in GitHub Desktop.
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
+ (CGFloat)getUIFontSize:(ASPUITextStyle)style traitCollection:(UITraitCollection *)contextTraitCollection { | |
bool isCompact = !(contextTraitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular); | |
CGFloat pointSize = (isCompact) ? 14.0f : 18.0f; | |
switch (style) { | |
case ASPUIElementStyleTitle1 : | |
pointSize = (isCompact) ? 36.0f : 36.0f; | |
break; | |
case ASPUIElementStyleTitle2 : | |
pointSize = (isCompact) ? 27.0f : 27.0f; | |
break; | |
case ASPUIElementStyleTitle3 : | |
pointSize = (isCompact) ? 18.0f : 18.0f; | |
break; | |
case ASPUIElementStyleLarge : | |
pointSize = (isCompact) ? 16.0f : 16.0f; | |
break; | |
case ASPUIElementStyleMedium : | |
pointSize = (isCompact) ? 14.0f : 14.0f; | |
break; | |
case ASPUIElementStyleSmall : | |
pointSize = (isCompact) ? 11.0f : 11.0f; | |
break; | |
case ASPUIElementStyleUnknown : | |
break; | |
} | |
// Adjust based on OS | |
return [self adjustBasedOnPreferredContentSizeCategory:pointSize]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment