I've navigated from view A to view B (with new navigation controller and black tinted navigation bar)
View A controller:
// With Navigation Controller
let storyBoard: UIStoryboard = UIStoryboard(name: "ViewB", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "ViewB") as! ViewBController
let navCont = UINavigationController(rootViewController: newViewController)
// Change the navigation bar to translucent
navCont.navigationBar.setBackgroundImage(UIImage(), for: .default)
navCont.navigationBar.shadowImage = UIImage()
navCont.navigationBar.isTranslucent = true
navCont.navigationBar.tintColor = UIColor.black
//present(navCont, animated: true, completion: nil)
show(navCont, sender: nil)
When navigating from view B to view C, I would like to change the navigationBar.tintColor from black to white.
View B Controller:
@IBAction func staticQRBtnPressed(_ sender: Any) {
// Without Navigation Controller
let storyBoard: UIStoryboard = UIStoryboard(name: "ViewC", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "ViewCController") as! ViewCController
newViewController.navigationController?.navigationBar.barTintColor = UIColor.white
newViewController.navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white]
self.show(newViewController, sender: nil) // Push to navigation stack
}
View C controller:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.barTintColor = UIColor.white
navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white]
}
Why are the above methods not working?