How to get a bold version of UIFont prefferedFontForTextStyle?

In iOS 7, users can manipulate their fonts from the control panel, which can help (among other things) people with visual impairments.

I am trying to work with a new paradigm using new methods created to support this functionality. For the most part, this is quite simple - just use [label setFont: [UIFont prefferedFontForTextStyle: UIFontTextStyleHeadline]] or any other format you need.

But sometimes I need to adjust them. For example, perhaps the title should be a little larger. I can use this answer to this question. Unfortunately, I cannot figure out how to apply this answer to other changes, for example, just shifting the font without resizing.

+6
source share
1 answer

You can try the following:

UIFontDescriptor *descriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleHeadline]; /// Add the bold trait descriptor = [descriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold]; /// Pass 0 to keep the same font size UIFont *font = [UIFont fontWithDescriptor:descriptor size:0]; 
+5
source

Source: https://habr.com/ru/post/955634/


All Articles