Reputation: 6119
I have several views in my Storyboard which have UILabel
s. These labels are set to Automatically Adjusts Font
and use text styles like Body
or Headline
.
I know there is a programmatic approach as such: https://useyourloaf.com/blog/using-a-custom-font-with-dynamic-type/
let label = UILabel()
label.font = scaledFont.font(forTextStyle: textStyle)
label.adjustsFontForContentSizeCategory = true
However, given that I have already laid out my labels and set their text styles, is there a way to use a custom font AND text styles from within interface builder? Or maybe somehow override their font-family while respecting the text style already set on them?
Upvotes: 1
Views: 1156
Reputation: 535925
No, you'd need to use the programmatic approach. However, it is easy to write a little loop that runs through all your labels and for each one, fetches the dynamic type "role" already set in interface builder and substitutes a UIFontMetrics value based on that "role" and the desired custom font.
Upvotes: 1