Adding custom font on iphone

Hi, can someone give me a detailed explanation of how to add a custom font to iphone shortcuts?

I already created a key on info.plist

<key>UIAppFonts</key> <array> <string>custom.ttf</string> </array> 

But I do not know what the next step.

+1
source share
1 answer

All custom fonts on iphone (development) should be added to info.plist app

Add row

 <key>UIAppFonts</key> <array>    <string>custom.ttf</string> </array> 

Then add custom.ttf to the project.

Subclass UILabel

 @interface CustomLabel : UILabel { } @end @implementation CustomLabel - (id)initWithCoder:(NSCoder *)decoder { if (self = [super initWithCoder: decoder]) { UIColor *textColor = [UIColor colorWithRed:0.20f green:0.20f blue:0.20f alpha:1.0f]; [self setTextColor:textColor]; [self setShadowColor:textColor]; [self setHighlightedTextColor:textColor]; [self setFont:[UIFont fontWithName:@"custom" size:self.font.pointSize]]; } return self; } @end 

So you're ready to create a custom font on your label.

Note:

For each shortcut added to the application that you want to have your own font, change the class identifier to CustomLabel (the name of the subclass is UILabel).

+4
source

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


All Articles