Skip to content

Instantly share code, notes, and snippets.

@bdalziel
Created July 27, 2016 21:54
Show Gist options
  • Save bdalziel/c83758961287aaec4bd2606a9e51d113 to your computer and use it in GitHub Desktop.
Save bdalziel/c83758961287aaec4bd2606a9e51d113 to your computer and use it in GitHub Desktop.
+ (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