Search code examples
iosiphonecocoa-touchuinavigationcontrollerstatusbar

How to slide in/out statusBar and navigationBar simultaneously?


I'd like to show and hide the statusBar and the navigationBar simultaneously using a slide effect.

This is how I tried:

[[UIApplication sharedApplication] setStatusBarHidden:hide withAnimation:UIStatusBarAnimationSlide];
[self.navigationController setNavigationBarHidden:hide animated:animated];

However, the duration of both animation is not the same. The status bar animation takes longer. I found no way how to specify the duration of either animation. Did I miss something obvious?


Solution

  • Clearly, there's no easy solution to do this right. Apple has to fix it.

    Of course, one work-around is to use alpha fading as Ephraim suggests. If you're insisting on the sliding behavior, I found it best to just animate the navigation bar and hide/show the statusBar without any animation. This looks much better than sliding the status bar because the gap between the bars during the animation is quite noticeable.