更新斯威夫特4後,我得到一個編譯器錯誤:UIAppearance斯威夫特4
Static member 'appearance' cannot be used on protocol metatype 'UIAppearance.Protocol'
這是我在我的自定義標籤欄控制器的子類viewWillAppear
方法,我設置的項目文本的字體。
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// compiler error on line below
UIAppearance.appearance().setTitleTextAttributes([NSAttributedStringKey.font: font], for: UIControlState.normal)
}
我無法解決這個問題,任何指導將不勝感激,謝謝!
該代碼應該做什麼?通常外觀是爲具體的UI類設置的,例如, 'UIBarItem.appearance()。setTitleTextAttributes ...' –
我會在問題中提供更多的上下文。這是一個自定義選項卡欄控制器類,我正在更改欄項目的字體。 –
您需要從UI類調用,而不是直接從'UIAppearance'調用。 – dimpiax