This is a quick tip that will show you how to show hide Navigation Bar when tap in iOS occurs. This is a great method if you want to benefit from every pixel of the screen real estate. So i suggest you doing it when you have an view that will display images in fullscreen. An example is when you want to show hide Navigation Bar when the user taps the screen.

A lot of top apps use the show hide Navigation Bar, mainly when opening an image. Twitter, Facebook, eBay and a plethora of famous apps are using this technique. Why not you?

I will show you how in these simple steps in the following code.

Code for show hide Navigation Bar

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showHideNavbar:)];
[self.view addGestureRecognizer:tapGesture];
-(void) showHideNavbar:(id) sender 
// write code to show/hide nav bar here 
// check if the Navigation Bar is shown
if (self.navigationController.navigationBar.hidden == NO)
// hide the Navigation Bar
[self.navigationController setNavigationBarHidden:YES animated:YES];
// if Navigation Bar is already hidden
else if (self.navigationController.navigationBar.hidden == YES)
// Show the Navigation Bar
[self.navigationController setNavigationBarHidden:NO animated:YES];

That’s all guys, now you got another tool that will make your app look cooler a more functional.

If you have any other idea how to implement this thing, leave a comment.

[alert style=”green”]You can follow me on Twitter in my personal profile or Duuro App Studio profile[/alert]

Don’t miss out on the latest articles

Sign up to our newsletter and stay in the loop