升级到Swift 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)
}
我在修复这个问题时遇到了困难,任何指导都将不胜感激,谢谢!
UIBarItem.appearance().setTitleTextAttributes ...
。 - Martin RUIAppearance
中调用。 - dimpiax