2

I have a full screen navigation menu that covers the entire screen. The problem I am facing is when I try to hide the status using:

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

The status bar hides but the view controller seems to shift up.

My view controller has this property set:

self.edgesForExtendedLayout = UIRectEdgeAll;

I thought that means the view controller's view appear underneath the status bar, regardless of the visibility of the status bar, the view controller should remain the same size, no ?

Is there a way to hide the status bar without affecting the height of the view controller's view ?

Zhang
  • 11,549
  • 7
  • 57
  • 87
  • possible duplicate of [Status bar and navigation bar appear over my view's bounds in iOS 7](http://stackoverflow.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bounds-in-ios-7) – Anbu.Karthik Jan 16 '15 at 06:00

2 Answers2

0

OK, seems like a stupid mistake on my part.

My View Controller should be using:

self.edgesForExtendedLayout = UIRectEdgeNone;

Instead of

self.edgesForExtendedLayout = UIRectEdgeAll;
Zhang
  • 11,549
  • 7
  • 57
  • 87
0

Swift 4!

If you are using UIApplication.shared.isStatusBarHidden = false, and are using something that uses UIScrollView, UICollectionView, etc., then doing

yourScrollView.contentInsetAdjustmentBehavior = .never

will prevent its contents from shifting.

Xavier L.
  • 709
  • 5
  • 21