我有下面的代碼,它在將我的應用程序更新到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