在 iOS 10 上處理沒有通知的首選文字大小更改
UILabel
,UITextField
和 UITextView
類具有從 iOS 10 開始的新屬性,用於在使用者更改其首選讀取大小 adjustsFontForContentSizeCategory
時自動調整其字型大小。
迅速
@IBOutlet var label:UILabel!
if #available(iOS 10.0, *) {
label.adjustsFontForContentSizeCategory = true
} else {
// Observe for UIContentSizeCategoryDidChangeNotification and handle it manually
// since the adjustsFontForContentSizeCategory property isn't available.
}