Here's one solution:
- hide the navigation bar of the navigation controller
- add a navigation bar to the root view controller of the navigation controller
- restore the swipe to back gesture to the navigation controller
For the last point you can add a pan gesture recognizer (suggested) or simply set the interactivePopGestureRecognizer's delegate of the navigation controller to nil:
self.navigationController?.interactivePopGestureRecognizer?.delegate = nil;
but please refer to this discussion for its implications: No Swipe Back when hiding Navigation Bar in UINavigationController
EDIT:
Working solution which fulfills the requirements: just setting the navigationBarHidden
in the viewWillAppear
does the magic.
I've setup a sample demo here: https://github.com/ldantona/NavigationBarExample
EDIT 2:
Just found this library, could it be of any help?
https://github.com/MoZhouqi/KMNavigationBarTransition
The library can capture the background style of the navigation bar in
the disappearing view controller when pushing, and when you pop back
to the view controller, the navigation bar will restore the previous
style, so you don't need to consider the background style after
popping. And you also don't need to consider it after pushing, because
it is the view controller to be pushed that needs to be considered.
Hope it helps