In Apple\'s recently released Remote app I noticed the way in which the navigation bar behaves is unique and I haven\'t been able reproduce it. When popping the Now Playing view
Instead of hiding and showing the navigation bar, you can update the alpha for the navigation bar. It will animate smoothly during the transition. For the view controller with transparent nav bar, instead of modifying the nav bar, create a navbar (or just the back button and title etc.) manually in the second controller's view. We will then hide the navbar when transitioning from first view controller to the second one.
On your first controller's viewWillDisappear
and on your second view controller's viewWillAppear:
, set the navigation bar alpha to zero using self.navigationController.navigationBar.alpha = 0;
. Since this is in animation block, this will make the navigation bar disappear during the push animation.
Set the alpha back to one in first controller's viewWillAppear
and second controller viewWillDisappear
.
I just downloaded the application to make sure. Two different navigation bars are used. You can see this by using the interactive pop gesture. Notice how the navigation bar on the bottom view controller slides in and out. During normal push and pop transitions, the navigation items just fade in and out on the existing bar, while the bar is stationary. This is what happens up until the point where the now playing view controller is pushed.
If you look quickly, during the now playing view controller animation, you can see the bottom navigation bar disappear.
From my experience with UIKit behavior and what I see in the app, here is what I think happens:
album_vc
= the bottom, list view controller
nowplaying_vc
= the top view controller
On nowplaying_vc
's viewWillAppear:
[self.navigationController setNavigationBarHidden:YES animated:YES];
. Since this is in animation block, this will make the navigation bar slide out during the push animation.[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
Pretty sure about this, because notice there is no animation in the transition of the status bar styles. It just becomes white.On nowplaying_vc
's viewWillDisappear:
[self.navigationController setNavigationBarHidden:NO animated:YES];
. Since this is in animation block, this will make the navigation bar slide in during the pop animation.[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
Again, notice how during interactive pop gesture, the status bar just changes with no animation.To achieve the transparent look of the navigation bar of nowplaying_vc
, you can use an empty image ([UIImage alloc]
) with setBackgroundImage:forBarPosition:barMetrics:
.
Since the application does not rotate, we can't be sure if the navigation bar on nowplaying_vc
is part of another navigation controller or just a navigation bar on the top with a position of UIBarPositionTopAttached
. For all we know, there isn't even a navigation bar there but just a back chevron image view (back bar button is comprised of an image view and a button).
I think the status bar style is changed in viewWillAppear:
and viewWillDisappear:
due to the unnatural feel there is during interactive pop gesture. I would recommend using an animated transition, or even better, use the new view controller-based status bar style, which the system animates transitions by itself.
Update for modern API:
You should use the animateAlongsideTransition:completion:
or animateAlongsideTransitionInView:animation:completion:
API, rather than relying on the implicit animations of viewWillAppear:
and viewWillDisappear:
.