Reputation: 5397
I have three controllers, each with different style on navigation bar
Controller A: white navigation bar, transparent status bar (so that the content is visible), achieved through custom bg image on navbar
Controller B: white navigation bar, white status bar, achieved through custom bg image on navbar
Controller C: navigation bar is hidden, there is just custom transparent view with buttons
Standard use case is A > B > C and back again
The problem is that there is just one navigation bar object and when I update it's visibility or background image, it applies for all view controller. So when I go from A to B, status bar turns white during transition. When I go from B to C, nav bar disappears even while B is still visible (or after it is gone, depending on whether I change navbar in viewWillAppear or viewDidAppear).
My goal is to have "separate" navbar style for all controller so that it won't change during transition, but the new controller slides in with it's own navbar while the old one goes away with his navbar style untouched.
Is something like this even possible without using my own UINavigationController implementation?
Upvotes: 1
Views: 549
Reputation: 4577
Yes, it's possible. UINavigationController has navigationBarHidden
property. Set it to true to hide the navigation controller holding the controller A, B and C.
Then add a navigation bar or a button to each child view controller (A, B and C) to be pushed/popped with the view controller.
You may need to call popViewControllerAnimated
when the back buttons of B and C are tapped.
Structure:
UINavigationController (with navigationBarHidden set to true)
|
+- UIViewController A
| |
| + UINavigationBar
|
+- UIViewController B
| |
| + UINavigationBar
|
+- UIViewController C
|
+ UIButton
Upvotes: 2