I have different bar tint colours for different view controllers. Some View Controllers' bar tint colour requires the title text colour to be white and other View Controllers' bar tint colour requires it to be black. Now the code (called in the viewWillAppear method) I'm using for the view controllers with the white navigation bars is:
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
self.navigationController?.navigationBar.tintColor = UIColor.blackColor()
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "someFont", size: 20)!, NSForegroundColorAttributeName: UIColor.blackColor()]
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.blackColor(), NSFontAttributeName: UIFont(name: "someFont", size: 17)!], forState: .Normal)
The code (called in the viewWillAppear method) I am using for the darker navigation bars is:
self.navigationController?.navigationBar.barTintColor = UIColor.blackColor()
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "someFont", size: 20)!, NSForegroundColorAttributeName: UIColor.whiteColor()]
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont(name: "someFont", size: 17)!], forState: UIControlState.Normal)
Now the problem is, my first two view controllers have white navigation bars, and my third view controller has a darker navigation bar.
Moving from the first to the second view controller, the back button appears normally, and is black. Moving from the second to third view controller the back button appears normally once again, and is white.
But after I press the back button on the third view controller and come to the second view controller, the back button remains white and is illegible (which I don't want). It turns black only when I tap on it; you can't see it before tapping on the top left corner. How do I make it black?
I've tried calling these methods in the viewDidLoad, the viewDidAppear and the viewWillAppear functions, but it just doesn't solve the problem.
I need help resolving this irritating glitch. Thanks.