我有下面的代码,它在将我的应用程序更新到Swift3之前曾经工作过。在iOS 10中更改UIBarButtonItem字体
let barButtonsAppearanceDictionary: [String : AnyObject] = [NSFontAttributeName : UIFont.tangraText(withSize: 17)!,
NSForegroundColorAttributeName : UIColor.tangraBlue()]
UIBarButtonItem.appearance().setTitleTextAttributes(barButtonsAppearanceDictionary, for: UIControlState())
let barButtonsDisabledAppearanceDictionary: [String : AnyObject] = [NSFontAttributeName : UIFont.tangraText(withSize: 17)!,
NSForegroundColorAttributeName : UIColor.lightGray]
UIBarButtonItem.appearance().setTitleTextAttributes(barButtonsDisabledAppearanceDictionary, for: .disabled)
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.tangraBlue(),
NSFontAttributeName : UIFont.tangraText(withSize: 22)!]
UINavigationBar.appearance().tintColor = UIColor.tangraBlue()
它应该改变导航栏项目的字体和颜色,但它不工作了。问题不在于字体,因为它在整个应用程序中都显示正确。有任何想法吗?
您的代码适用于xcode 8中的我。我能够看到ui barbutton的文本颜色更改。 –
代码updated.take ... – Joe
@NaveenRamanathan奇怪。您是否使用自定义字体进行尝试? – smeshko