為整個iOS應用設置默認字體?我有一個自定義字體,我想用于在我的應用程序,標簽,文本視圖等中顯示文本的所有內容。有沒有辦法為整個應用程序設置默認字體(默認標簽使用SystemFont)?
3 回答

ITMISS
TA貢獻1871條經驗 獲得超8個贊
還有另一種解決方案是覆蓋systemFont。
只需創建一個類別
UIFont + SystemFontOverride.h
#import <UIKit/UIKit.h>@interface UIFont (SystemFontOverride)@end
UIFont + SystemFontOverride.m
@implementation UIFont (SystemFontOverride)#pragma clang diagnostic push#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize { return [UIFont fontWithName:@"fontName" size:fontSize];}+ (UIFont *)systemFontOfSize:(CGFloat)fontSize { return [UIFont fontWithName:@"fontName" size:fontSize];}#pragma clang diagnostic pop@end
這將取代默認實現,大多數UIControl使用systemFont。
- 3 回答
- 0 關注
- 861 瀏覽
添加回答
舉報
0/150
提交
取消