2

I have one main Navigation Controller, where I set the the background color

 override func viewDidLoad() {
    super.viewDidLoad()

    self.navigationBar.backgroundColor = UIColor.blue
    self.navigationBar.isTranslucent = false
}

But, in that case my nav bar becomes completely white. When I set isTranslucent to true my navigation bar becomes transparent, but that is not actually what I need. I want to have just blue navigation bar.

Just in case in my Nav Controller I have overried

override var preferredStatusBarStyle: UIStatusBarStyle{ return .lightContent }

And in AppDelegate set tint color

UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]

Commenting tintColor didn't help me either.

This is my "blue" navigation bar

dand1
  • 371
  • 2
  • 8
  • 22

2 Answers2

5

Use below code to change the colour of the navigation-bar.

self.navigationBar.translucent = false
self.navigationBar.barTintColor = UIColor.blue
Nishant Bhindi
  • 2,242
  • 8
  • 21
0

You need to set barTint color instead of tintColor

self.navigationBar.barTintColor = UIColor.blue
KKRocks
  • 8,222
  • 1
  • 18
  • 84