Mike_NotGuilty Mike_NotGuilty - 1 year ago 128
iOS Question

Swift - UINavigationController bar color does not change programmatically

I have a problem with changing the background color of my

Here's what I tried so far:

self.navigationController?.navigationBar.translucent = true
self.navigationController?.navigationBar.backgroundColor = UIColor.blueColor()

The navigation bar does not change. Even setting the translucency to true has no effect at all.
I can change the tint color without any problems, but not the background color.

But if I change the color in the storyboard, it works fine!

Is there an option in the storyboard that I enabled/disabled by mistake? Can someone help me with this? Thanks.

Answer Source

You should set the navigation bar's barTintColor instead of backgroundColor. This should be what you are looking for.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download