9

I have a problem with changing the background color of my UINavigationBar. 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.

Mike_NotGuilty
  • 2,253
  • 5
  • 32
  • 64

1 Answers1

19

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

JoeFryer
  • 2,751
  • 1
  • 18
  • 23