The Apple documentation says that for iOS an app can use text styles and dynamic font type so text size automatically adjusts to the users reading preferences.
I have a text style Body
and set Dynamic Type
to true
so that it automatically adjust the text size. This works good.
This text I would also like to make appear bold
. I haven't found a way yet how to achieve this either by code or in the Interface Builder.
Is there a way to achieve a "bold dynamic font type"?
Ok, it seems the documentation provides a hint. For using custom fonts, I consider a bold
font as a custom font now, one can use the UIFontMetrics
class.
If I pass a "bold custom font" to the scaledFontForFont
method of UIFontMetrics
class I get the desired result with the dynamic font type UIFontTextStyleBody
.
UIFont* boldSystemFont = [UIFont boldSystemFontOfSize:17];
myLabel.font = [[UIFontMetrics metricsForTextStyle:UIFontTextStyleBody] scaledFontForFont:boldSystemFont];
So far I only see this way using code. No idea if this could somehow be setup in the Interface Builder as well.