How can I use the dynamic type text style "Title 1" and set the font face to the built-in font Chalkboard SE for a UILabel in a storyboard?
I need to honor the Dynamic Type size in iOS (Apple has been encouraging this since iOS 7?) I also need to use the built-in font Chalkboard SE, which is not used by default for the "text styles" fonts. I am currently using a custom font as shown in the image, but need the font to change size in accordance with the user's Dynamic Type/Accessibility Sizes preference just as all the Text Styles fonts do. The best Text Styles option is Title 1, but the font/typeface is unacceptable.
Although you can't specify both a custom font and a preferred text style via Storyboard, it's not difficult to programmatically specify a dynamic type size for your custom font:
Swift:
let pointSize = UIFontDescriptor.preferredFontDescriptorWithTextStyle(UIFontTextStyleTitle1).pointSize
let customFont = UIFont(name: "Chalkboard SE", size: pointSize)
When you receive a UIContentSizeCategoryDidChangeNotification
, use the same code to update your label's font.
Obj C:
CGFloat pointSize = [[UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleHeadline] pointSize];
[titleLabel setFont:[UIFont fontWithName:@"Marker Felt" size:pointSize]];