How in iOS hide status bar
July 30, 2015
In case you need to know how in iOS hide status bar, then you can at least do it with style. Sweet little animation will change the whole impression of your status bar disappearance.
Since iOS7 you now can specify per view wether hide or show your status bar. Veeery handy. So lets imagine that you made a button that is connected to the
@property BOOL shouldBeHidingStatusBar;
- (BOOL)prefersStatusBarHidden {
return self.shouldBeHidingStatusBar;
}
- (IBAction)hideStatusBar {
self.shouldBeHidingStatusBar = YES;
[UIView animateWithDuration:0.5 animations:^{
[self setNeedsStatusBarAppearanceUpdate];
}];
}
Pretty nice, isn't it? But in case you want it to slide up, which looks even cooler - here is what it should look like now:
@property BOOL shouldBeHidingStatusBar;
- (BOOL)prefersStatusBarHidden {
return self.shouldBeHidingStatusBar;
}
- (IBAction)hideStatusBar {
self.shouldBeHidingStatusBar = YES;
[UIView animateWithDuration:0.5 animations:^{
[self setNeedsStatusBarAppearanceUpdate];
}];
}
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
return UIStatusBarAnimationSlide;
}
That is it, now you can hide you status bar with style and moreover - control manually on which views to show it and on which views to hide with no sweat.