How to use a custom font with dynamic text sizes in iOS7

前端 未结 12 2102
长情又很酷
长情又很酷 2020-11-29 14:41

In iOS7 there are new API\'s for getting a font that is automatically adjusted to the text size the user has set in their preferences.

It looks something like this to

12条回答
  •  时光说笑
    2020-11-29 15:23

    This is how I update the font of a prefferedFontForTextStyle:

    UIFont *font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
    UIFontDescriptor *fontDesc = [font fontDescriptor];
    fontDesc = [fontDesc fontDescriptorByAddingAttributes:@{UIFontDescriptorNameAttribute : @"Helvetica",
                                                            UIFontDescriptorSizeAttribute : @16}];
    
    font = [UIFont fontWithDescriptor:fontDesc
                                 size:[fontDesc pointSize]];
    

提交回复
热议问题