Dawid
Dawid

Reputation: 145

hide navbar when tapped

I am making a slideshow for in my app. I want it almost like the photo app of Apple. It is almost finished just some small issues. I want to hide the navbar when tapped on the screen and show it when tapped again. But I am not sure how to do this.

Upvotes: 1

Views: 405

Answers (4)

Denis Sernuk
Denis Sernuk

Reputation: 1

Make navigation translucent

self.navigationController.navigationBar.barStyle=UIBarStyleBlackTranslucent; 

Upvotes: 0

iOSPawan
iOSPawan

Reputation: 2894

  1. Add Gesture to Screen using

UITapGestureRecognizer *theSingleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self

action:@selector(handleSingleTapForImage:)]; [inImageView addGestureRecognizer:theSingleTapGesture]; [theSingleTapGesture release];

  1. In gesture method show or hide NavigationBar

    -(void)handleSingleTapForImage:(UITapGestureRecognizer *)sender {
    [self.navigationController setNavigationBarHidden:![self.navigationController isNavigationBarHidden] animated:YES];
    

    }

Upvotes: 0

Jano
Jano

Reputation: 63667

// catch the screen tap and call a method to hide the navigation bar
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleNavBar:)];
[self.view addGestureRecognizer:gesture];
[gesture release];

- (void)toggleNavBar:(UITapGestureRecognizer *)gesture {
    BOOL barsHidden = self.navigationController.navigationBar.hidden;
    [self.navigationController setNavigationBarHidden:!barsHidden animated:YES];
}

Upvotes: 2

Michael Dautermann
Michael Dautermann

Reputation: 89509

How do you want to hide the navigation bar? Tapping in the navigation bar (which would be quite tricky, if not downright impossible) or via some other button or via another method?

In general, you can definitely hide the navigation bar.

Look at [UINavigationController setNavigationBarHidden: animated:] (I've linked the Apple documentation)

Upvotes: 1

Related Questions