iOS: 有没有办法以编程方式将故事板的所有字体设置为特定字体?
iOS: Is there a way to set programmatically all the fonts of the storyboard in a specific font?
我想知道是否有一种简单的方法可以更改 StoryBoard 中所有标签、文本视图、按钮、talbeviewcells 等的字体,而无需将它们添加到 viewcontroller?
我现在手动完成,但我想知道是否存在简单的解决方案?
在代码中试试这个
Swift
UILabel.appearance().defaultFont = UIFont.systemFont(ofSize: 25)
更新:
Obj-c(不改变大小):
放在开头:
@implementation UILabel(SizedFontName)
- (void)setSizedFontName:(NSString *)name UI_APPEARANCE_SELECTOR
{
self.font = [UIFont fontWithName:name size:self.font.pointSize];
}
@end
在 viewDidLoad 中:
[[UILabel appearance] setSizedFontName:@"RenaultLife"];
我想知道是否有一种简单的方法可以更改 StoryBoard 中所有标签、文本视图、按钮、talbeviewcells 等的字体,而无需将它们添加到 viewcontroller?
我现在手动完成,但我想知道是否存在简单的解决方案?
在代码中试试这个
Swift
UILabel.appearance().defaultFont = UIFont.systemFont(ofSize: 25)
更新:
Obj-c(不改变大小):
放在开头:
@implementation UILabel(SizedFontName)
- (void)setSizedFontName:(NSString *)name UI_APPEARANCE_SELECTOR
{
self.font = [UIFont fontWithName:name size:self.font.pointSize];
}
@end
在 viewDidLoad 中:
[[UILabel appearance] setSizedFontName:@"RenaultLife"];