Reputation: 334
I need to change status bar style depending on the view controller so in my plist-file "View controller-based status bar appearance" is set to YES.
And I need to sometimes hide the status bar!
I'm trying to use setStatusBarHidden but it seems to work only if "View controller-based status bar appearance" is set to NO ...
So is there a way to hide the status bar ?
Upvotes: 4
Views: 811
Reputation: 6648
First, declare a variable to indicate hidden or not:
@interface ExampleViewController
{
BOOL statusBarHidden;
}
Second, override UIViewController's method which depends the variable:
- (BOOL)prefersStatusBarHidden {
return statusBarHidden;
}
Finally, when you need to hide status bar, do:
statusBarHidden = YES;
[self setNeedsStatusBarAppearanceUpdate];
When you need to display status bar again, do:
statusBarHidden = NO;
[self setNeedsStatusBarAppearanceUpdate];
Upvotes: 1