Search code examples
iosshow-hidealphanavigationbarscreen-rotation

Stop navigation bar from reappearing after rotate


I have an app where the user can tap the screen and the navigation bar will fade out (I do this by setting the alpha to 0), but when the device is rotated the navigation bar reappears (I guess the alpha is reset to 1?). How can I prevent this behaviour?

The navigation bar stays hidden if I use [self.navigationController setNavigationBarHidden:YES animated:YES] instead, but that doesn't give me the fade effect I want.

Is there another way to do the fading effect?

Thanks


Solution

  • I assume you're animating out the navigation bar with the alpha? Why not hide the navigation bar once you're finished?

        [UIView animateWithDuration:1.0
                     animations:^{
                         self.navigationController.navigationBar.alpha = 0;
                     } completion:^(BOOL finished) {
                         [self.navigationController setNavigationBarHidden:YES animated:NO];
                     }];