How to set the top position = 0 after setStatusBarHidden:Yes?

后端 未结 6 408
栀梦
栀梦 2020-12-09 11:26

I found that after setting the

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]

at viewDidLoad, then if

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 12:07

    Justin Gallagher's solution is almost right, but has one major side effect.

    Hiding the status bar and then setting the view's frame to its own bounds will work in the current orientation. But rotation will be ugly. If you are in portrait, for instance, rotating the device to landscape will cause the entire view's frame to be shifted to the right 256 points, leaving a large black space on screen.

    bmoeskau's solution (to another side effect) in the comments above avoids this problem:

    [self.view setFrame: [[UIScreen mainScreen] bounds]];
    

提交回复
热议问题