In iOS 7 if I hide the status bar with the `prefersStatusBarHidden` method, the navigation bar shrinks/loses height. Can I stop this behaviour?
ios, ios7, objective-c
Solution
The navigation bar is keeping its height, it's just that the navigation bar and status bar don't have any separator between them (and have the same background), so they appear to be one thing, when, in fact, they are two. So what you really want is for the navigation bar to expand to take up the space previously occupied by both the navigation bar and the status bar.
I've done it like this before (heightCon is an IBOutlet to a height constraint on the navigation bar).
-(IBAction)hideStatusBar:(id)sender {
static BOOL hidden = YES;
[[UIApplication sharedApplication] setStatusBarHidden:hidden withAnimation:UIStatusBarAnimationSlide];
self.heightCon.constant = (hidden)? 64 : 44;
[UIView animateWithDuration:0.35 animations:^{
[self.navBar layoutIfNeeded];
}];
hidden = ! hidden;
}
Problem
On iOS 7, if I use the `prefersStatusBarHidden` method and return an instance variable that can be changed: ``` - (BOOL)prefersStatusBarHidden { return self.statusBarShouldBeHidden; } ``` And I change the instance variable, thus hiding the status bar, the navigation bar loses the 20pt of height that the status bar occupies. I don't want this, however. Is it possible to hide the status bar but keep the height of the navigation bar?