-
-
Save vinhnx/2d570cbcc0c8f68b809e to your computer and use it in GitHub Desktop.
Toggle status bar and navigation bar together
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment