Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created May 8, 2014 08:37
Show Gist options
  • Save odrobnik/2106f26379fd609d4ed3 to your computer and use it in GitHub Desktop.
Save odrobnik/2106f26379fd609d4ed3 to your computer and use it in GitHub Desktop.
Toggle status bar and navigation bar together
- (IBAction)handleTap:(id)sender
{
BOOL isHiding = !_statusBarHidden;
_statusBarHidden = isHiding;
[UIView animateWithDuration:UINavigationControllerHideShowBarDuration delay:0 options:0
animations:^{
[self setNeedsStatusBarAppearanceUpdate];
}
completion:NULL];
if (!isHiding)
{
NSLog(@"Hidden");
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
else
{
NSLog(@"not hidden");
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
}
#pragma mark - Bar Appearance
- (BOOL)prefersStatusBarHidden {
return _statusBarHidden;
}
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation
{
return UIStatusBarAnimationSlide;
}
@ksm
Copy link

ksm commented Oct 1, 2015

Have you found a way to fade both the navigation bar and the status bar, rather than slide them away?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment