如果我收到推送通知,但嘗試更改我的導航欄的色調但不起作用。當收到PushNotif時,在AppDelegate中更改NavBar的着色顏色
我想它的工作方式是:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
self.setupUserInterface(color: UIColor(red: 208.0/255.0, green: 2.0/255.0, blue: 27.0/255.0, alpha: 1.0))
}
func setupUserInterface(color color: UIColor) {
// Navigation Bar
UINavigationBar.appearance().barTintColor = color
if let barFont = UIFont(name: "Avenir-Medium", size: 17.0) {
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor(), NSFontAttributeName:barFont]
}
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
// Status Bar
UIApplication.sharedApplication().statusBarStyle = .LightContent
}
我知道PushNotif被正確接收和其他一切工作正常,但用戶界面不會對此作出迴應。我需要以不同的方式改變它嗎?
你的函數被調用了嗎? – NSGangster
是的,但沒有任何變化 – sesc360
更改UIAppearance只會改變製作的新navBar,而不是NavBar已經制作的實例。我現在正在處理一個涉及UINavigationBar類擴展的答案。 – NSGangster