Reputation: 93
When I switch to another screen, the navigation bar (white) turns gray (if I put another color took a darker shade of the same color)
This is my code to choose the color
self.navigationController!.navigationBar.barTintColor = UIColor.whiteColor()
self.navigationController!.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.blackColor()]
self.navigationController!.navigationBar.translucent = false
Any idea to prevent this from happening and keep the color I want
Upvotes: 0
Views: 816
Reputation: 4941
Try below, it will surely works.
self.navigationController!.navigationBar.translucent = false;
self.navigationController!.navigationBar.barTintColor = UIColor.whiteColor()
self.navigationController!.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.blackColor()]
while going to other screen your navigation bar turns gray because, On iOS7 and later, translucent
property of UINavigationBar
is true by default.
Upvotes: 2
Reputation: 2423
Try this :
1)
var controller= UINavigationController(rootViewController:YourViewController)
controller.navigationBar.tintColor = [UIColor whiteColor];
2)
var navigationBarAppearace = UINavigationBar.appearance()
navigationBarAppearace.tintColor = UIColor.whiteColor()
navigationBarAppearace.barTintColor = UIColor.whiteColor()
Upvotes: 0