I'm implementing a theme in my application and I ran into a weird bug (feature?). For some odd reason, I can't use UIView.animate
in my custom UITabBarController class to animate a change in color of my UITabBar but the same exact code works perfectly in the custom class of my UINavigationController.
Am I missing something? Is there something else I can use to animate the color change? I've scoured the Apple Documents but found nothing.
Here is the code I'm using in both cases:
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
})
}
}
And:
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
})
}
}
You can use UIView.transitionWithView to fade between the two states
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With