我目前正在使用 Swift 构建 iOS 应用程序,但遇到了一些问题。我的设置 View 是一个 TableView Controller 。这是一组的。我的表格 View 是动态的,字体也是动态的。
我想通过设置应用程序与字体大小的更改进行交互。
如果我的应用程序已经在运行,字体大小会发生变化,但布局会被破坏。 (字体由最小变为最大)
图片:Layout bug
如果我使用新的字体设置重新启动应用程序,就不会出现问题...
这是一个 XCODE project example ,您会看到该错误。
您能帮我找到解决方案吗?谢谢。
最佳答案
UIContentSizeCategory DidChangeNotification
就是您要寻找的内容。
根据文档:
Posted when the user changes the preferred content size setting.
This notification is sent when the value in the preferredContentSizeCategory property changes. The userInfo dictionary of the notification contains the UIContentSizeCategoryNewValueKey key, which reflects the new setting.
回调实现示例:
func handleContentSizeCategoryDidChangeNotification(notification: NSNotification) {
self.questionLabel.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
}
关于ios - 字体大小更改部分页脚 TableView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36365902/