简体   繁体   中英

Dynamic Text Size and System Font in iOS

I can't really understand why in the world Apple decided to fix the font family to the system font when using Text Sizes. I saw a couple of tricks here on Stackoverflow that let me change font descriptor programmatically in relation to user preferences but I'm not agree with those solutions. I use Storyboard to define the 90% of the text elements in my application. It doesn't make any sense to manually set all these elements.

That said, my question is: "Is it possible to handle text size from storyboard even using a custom font?" . I'm pretty sure that there is something that I'm missing... it doesn't make any sense that Apple is heavily pushing for this feature and at the same time they ask to use only system font.

After IOS 8 not support for custom font.

if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) {
                    //older than iOS 8 code here

                    [button.titleLabel setFont:[UIFont fontWithName:@"Your Custom Font" size:12]];
                }
                else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {

                    [button.titleLabel setFont:[UIFont fontWithName:nil size:12]];
                }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM