Search code examples
iosswiftuinavigationbaruinavigationcontroller

UINavigationBar color is getting change after pushing a view controller


I'm facing a wired issue related to navigation bar color. Please check below images.

Image 1

enter image description here

Image 2

enter image description here

Image 1 is a home view controller and image 2 is a second view controller that I'm pushing on home view controller.

In AppDelegate.swift I have set following...

UINavigationBar.appearance().backgroundColor = UIColor.clear
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().barTintColor = Color.red
UINavigationBar.appearance().shadowImage = UIImage();
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]

Please watch till end the below image you will get an idea about issue. I've reduced animation speed so you can get an idea about it.

enter image description here

Please help me out this issue. Any help will be appreciated !!

Thank you in advance.


Solution

  • Uncheck the translucent property of UINavigationBar as below-

    enter image description here

    OR

    self.navigationController?.navigationBar.isTranslucent = false