此属性仅适用于 iOS 10+ 操作系统什么是替换属性的替代解决方案。
Apple documentation for Objective C
@property(nonatomic) BOOL adjustsFontForContentSizeCategory;
var adjustsFontForContentSizeCategory: Bool { get set }
当我们在低版本应用程序中打开时崩溃时,此属性在低版本中不起作用。
最佳答案
在较低版本中,没有定义的属性,您必须以编程方式处理它,您必须监听字体更改的系统通知 - UIContentSizeCategoryDidChangeNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didChangePreferredContentSize:)
name:UIContentSizeCategoryDidChangeNotification
object:nil];
快速版本
NotificationCenter.default.addObserver(self, selector:
#selector(self.didChangePreferredContentSize), name:
UIContentSizeCategoryDidChangeNotification, object: nil)
然后您可以在选择器方法 - didChangePreferredContentSize 中处理您的要求。
最佳实践指南 - 一旦离开 View Controller ,请记住移除观察者。
关于ios - adjustsFontForContentSizeCategory iOS 的替代方案是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45094802/