How to hide navigation elements with swishy animations

You can hide (and show) navigation bars and toolbars from your UINavigationController with extremely funky animations, much like we see in the Photos app on iOS. In the app, when you single-tap the screen, both top and bottom toolbars disappear.

Here’s how we do that: Provided you have your view controller embedded in a UINavigationController, you can call the following methods to slide the top and bottom bars in and out:

// hide both bars
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.navigationController setToolbarHidden:YES animated:YES];

// and bring them back
[self.navigationController setNavigationBarHidden:NO animated:YES];
[self.navigationController setToolbarHidden:NO animated:YES];

On the same note, you can do the same (and better) with the status bar at the very top of your screen (that’s the one that contains the time and carrier).

// hide the status bar
[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];

// and bring it back
[[UIApplication sharedApplication]setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];

Here you even have a choice of

  • UIStatusBarAnimationSlide
  • UIStatusBarAnimationFade
  • UIStatusBarAnimationNone




Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.