ios swift - navigation item background turns black when going back to a screen where the navigation bar is hidden

Have you tried the animated method of hiding the navigation bar setNavigationBarHidden(_ hidden: Bool, animated: Bool)?


For Swift3.0

Add below code in First ViewController

override func viewWillAppear(_ animated: Bool) {
     super.viewWillAppear(true)
     navigationController?.setNavigationBarHidden(true, animated: animated)
}

Add below code in Second ViewController

func backButtonPressed() {
    navigationController?.setNavigationBarHidden(false, animated: false)
    navigationController?.popViewController(animated: true)
}