如何从iOS设置中检测动态字体大小更改? [英] How to detect Dynamic Font size changes from iOS Settings?
本文介绍了如何从iOS设置中检测动态字体大小更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
内部设置 - >常规 - >文字大小,更改文字大小后,我必须退出自己的应用以将尺寸应用于
Inside settings->general->text size, after changing the text size, I'd have to exit my own app to have the sizes applied to
[UIFont preferredFontForTextStyle:..]
是否有委托或通知通知我的应用程序重新应用新的尺寸?
Is there a delegate or notification to notify my app to re-apply the new sizes?
更新:我尝试了以下但有趣的是,字体大小将适用于我BG并启动应用程序TWICE。
Update: I tried the following but interestingly, the font size will apply after I BG and launch the app TWICE.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fromBg:) name:UIApplicationDidBecomeActiveNotification object:nil];
}
-(void) fromBg:(NSNotification *)noti{
self.headline1.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
self.subHeadline.font = [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
self.body.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
self.footnote.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
self.caption1.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
self.caption2.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2];
// [self.view layoutIfNeeded];
}
推荐答案
你听对于 UIContentSizeCategoryDidChangeNotification
。
Swift 3.0:
NSNotification.Name.UIContentSizeCategoryDidChange
这篇关于如何从iOS设置中检测动态字体大小更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文