How do I set a custom font for the whole application?

前端 未结 5 492
猫巷女王i
猫巷女王i 2020-12-09 06:02

Is there any way to How to Apply global font [new custom font] to whole application in iphone objective-c.

I know that we can use below method to set font for each l

5条回答
  •  没有蜡笔的小新
    2020-12-09 06:38

    CustomLabel.h

    #import 
    
    @interface VVLabel : UILabel
    
    @end
    

    CustomLabel.m

    #import "CustomLabel.h"
    #define FontDefaultName @"YourFontName"
    @implementation VVLabel
    - (instancetype)initWithCoder:(NSCoder *)aDecoder {
        self = [super initWithCoder: aDecoder];
        if (self) {
            // Initialization code
            // Static font size
            self.font = [UIFont fontWithName:FontDefaultName size:17];
    
    
            // If you want dynamic font size (Get font size from storyboard / From XIB then put below line)
            self.font = [UIFont fontWithName:FontDefaultName size:self.font.pointSize];
    
        }
        return self;
    }
    

提交回复
热议问题