I want one of my pushed viewControllers in a navigation controller stack to be "full screen" - no navigation bar and no status bar. I have this code that hides and shows the navigation bar in one of the view controllers of navigation controller (I want it to be pushed on full screen):
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated:animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.setNavigationBarHidden(false, animated:animated)
}
In the same viewController I'm also hiding the status bar with this:
override var prefersStatusBarHidden: Bool {
return true
}
It is hiding and showing as expected but the problem is that I get a black stripe on the transition when pushing this view controller and back from it (see images).
Push to this controller: Push to this controller
And back from this controller (back button):
It appears this is happening because of the prefersStatusBarHidden function Removing this solves the issue.
The code for show/hide the nav bar is taken from: https://stackoverflow.com/a/2406167/4207465
and based on apple developer library: "Showing and Hiding the Navigation Bar - When a navigation bar is used in conjunction with a navigation controller, you always use the setNavigationBarHidden:animated: method of UINavigationController to show and hide the navigation bar..."
Not sure why it's happening, Thanks for the help!