【发布时间】:2015-08-22 03:24:10
【问题描述】:
我正在我的应用程序中实现一个主题,但遇到了一个奇怪的错误(功能?)。出于某种奇怪的原因,我不能在我的自定义 UITabBarController 类中使用 UIView.animate 来为我的 UITabBar 的颜色变化设置动画,但是相同的确切代码在我的 UINavigationController 的自定义类中完美运行。
我错过了什么吗?还有什么我可以用来为颜色变化设置动画的吗?我搜索了 Apple 文档,但一无所获。
这是我在这两种情况下都使用的代码:
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
})
}
}
【问题讨论】:
标签: ios swift animation uinavigationcontroller uitabbarcontroller