它是如何animationUINavigationBar的条形颜色的变化,而不是一个UITabBar?

我在我的应用程序中实现了一个主题,我遇到了一个奇怪的bug(function?)。 出于一些奇怪的原因,我不能在我的自定义UITabBarController类中使用UIView.animate来animationUITabBar的颜色变化,但是相同的确切代码在我的UINavigationController的自定义类中完美地工作。

我错过了什么吗? 有什么我可以用来animation的颜色变化? 我扫了苹果文件,却什么都没发现。

这里是我在这两种情况下使用的代码:

 class customNavigationController: UINavigationController { @IBOutlet weak var navBar = ThemeManager.navigationbar func dusk(notification: NSNotification) { UIView.animateWithDuration(1, animations: { self.navBar?.barTintColor = UIColor(red: 79/255, green: 79/255, blue: 79/255, alpha: 1) self.navBar?.barStyle = UIBarStyle.Black }) } } 

和:

 class customTabController: UITabBarController { @IBOutlet weak var tab = ThemeManager.tabbar func dusk(notification: NSNotification) { UIView.animateWithDuration(1, animations: { self.tab?.barTintColor = UIColor(red: 79/255, green: 79/255, blue: 79/255, alpha: 1) self.tab?.barStyle = UIBarStyle.Black }) } } 

你可以使用UIView.transitionWithView在两个状态之间淡入淡出

 UIView.transitionWithView(self.tab!, duration: 1.0, options: .BeginFromCurrentState | .TransitionCrossDissolve, animations: { () -> Void in self.tab!.barTintColor = UIColor(red: 79/255, green: 79/255, blue: 79/255, alpha: 1) self.tab!.barStyle = UIBarStyle.Black }, completion: nil) 

那么要亲自改变标签栏上的颜色,我使用不同颜色的完全不同的图像 在这里输入图像说明

正如你所看到的,我select的图像是我的第二个图像。 现在它不会显示该图像,除非我将它添加到我的“用户定义的运行时属性”

在这里输入图像说明

将“Keypath”设置为“selectedImage”,types为“Image”,图像的值将显示在屏幕上。 我希望这回答了你的问题。