【发布时间】:2014-04-04 16:47:06
【问题描述】:
我在我的应用程序中使用 iOS 7 文本样式。当用户更改它们时,我想调整我的 UI。
我知道我可以注册UIContentSizeCategoryDidChangeNotification:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contentSizeCategoryDidChangeNotification:)
name:UIContentSizeCategoryDidChangeNotification object:nil];
但我不太确定如何更新字体大小,除了这样的:
- (void)contentSizeCategoryDidChangeNotification:(NSNotification *)notification {
_label1.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_label2.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
_label3.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_label4.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_label5.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_label6.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
[self.view setNeedsLayout];
[self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationNone];
}
我真的不想在代码中指定每种字体样式,因为我已经在情节提要中指定了它们,但我不知道我还能在这里做什么。有更好的解决方案吗?
【问题讨论】:
标签: ios7 uikit accessibility