Search code examples
swiftuinavigationcontrolleruinavigationbarbartintcolor

Navigation item color behave like previous controller. How can I fix this?


I have a quick question about navigation item color behavior. For example my "A" controller's navigation item color is red. And "B" controller's navigation item color is default (blue). When I push from main controller to "A" controller and then go to "B" controller, this "B" controller's navigation item color displaying red. But it should be default color!!

I mean second controller behave like previous controller. Have you any idea about that ?


Solution

  • Can you try set this code in your B Controller?

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        navigationController?.navigationBar.tintColor = .systemBlue
    }