Search code examples
iosobjective-cstatusbar

Show status bar with animation causes view to move up 20px so its under the status bar


I have a UIViewController that shows and hides the status bar. Hiding the status bar works no problem, however when I show the status bar using:

 [[UIApplication sharedApplication] setStatusBarHidden:NO                                         withAnimation:UIStatusBarAnimationSlide];

Causes the contents of the View to move up 20px so it ends up under the status bar. I dont know what else I can provide but this description, all that happens is when I hide the status bar, there is 20px of white space at the top where the status bar would be (this is what I want) but when I show the status bar the view moves up under the status bar (this is not what I want). The desire is to show and hide the status bar without effecting the UIViewController and its contents.


Solution

  • I solved this by removing auto-layout on this ViewController and manually set the views layout in :

    -(void)viewDidLayoutSubviews
    

    Seems to solve the issue. Cheers to @ThatGuy for pushing me in the right directions.