首先,定义好字体样式plist配置文件
然后写一个类,封装plist字体配置文件读取、给UILabel设置字体、UIButton设置字体、UITextfiled设置字体 ....
#import <Foundation/Foundation.h> @interface FontManager : NSObject @property (nonatomic, strong, readonly) NSDictionary *fontList; + (instancetype)sharedManager; //加载本地字体Plist文件 //- (void)setupFontList; //给Label设置字体 - (void)setLabel:(id)sender withText:(NSString*)aText andFontKey:(NSString*)key; //给Button设置字体 - (void)setButton:(id)sender fontKey:(NSString*)fontKey buttonState:(UIControlState)controlState; //给Textfiled设置字体 - (void)setTextfiled:(id)sender WithText:(NSString*)aText Fontkey:(NSString*)key PlaceHolderKey:(NSString*)placeHolder; - (UIFont*)getFontWithFontKey:(NSString*)key; - (UIColor*)getColorWithFontKey:(NSString*)key; @end
剩下 .m实现就不贴了,很简单。
时间: 2024-12-12 00:41:35