3

I have a UIViewController that is conditionally hiding the status bar in the application, but a problem I'm having is that when I have the status bar hidden and I change to a different application with a status bar, the view moves up 20 pixels to compensate for the missing status bar, even though I've already compensated for it.

I'm hiding the status bar like so:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

and showing it again with:

[[UIApplication sharedApplication] setStatusBarHidden:NO];

I've also tried adding this to my hide:

[self setWantsFullScreenLayout:YES];

and this to my show:

[self setWantsFullScreenLayout:NO];

Why is my view adjusting automatically upon me switching applications?

RileyE
  • 10,874
  • 13
  • 63
  • 106

1 Answers1

0

You only need to compensate for the StatusBar being shown.

By default, the top 20px of your view will sit under the StatusBar.

When you setStatusBarHidden:YES, you don't need to move your view 20px up unless you already moved it 20px down when setStatusBarHidden:NO.

Irfan
  • 4,301
  • 6
  • 29
  • 46
Bret Deasy
  • 820
  • 6
  • 14