I want to change UINavigationBar color globally for the whole application from the AppDelegate. For it I do:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
UINavigationBar.appearance().tintColor = UIColor(red: 63, green: 172, blue: 236, alpha: 1)
}
but, I do not know why, it doesn't change the color of my Navigation bar.
I had connect Navigation Bar as Editor > Embed In > Navigation Controller
How can I set the color for NavBar?
set barTintColor
UINavigationBar.appearance().barTintColor = UIColor(red: 63.0/255.0, green: 172.0/255.0, blue: 236.0/255.0, alpha: 1.0)
I think you forgot to divide with 255
For turn off the translucent
. In your first root controller do it as follows.
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController!.navigationBar.translucent = false
}
Swift 3 :
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController!.navigationBar.isTranslucent = false
}
My output:
Use this
navigationController.navigationBar.barTintColor = UIColor.greenColor()
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