Search code examples
iosiphoneios11safearealayoutguide

NavigationBar without statusbar overlaps safearea in iOS11


I have a problem in iOS11 with the iPhoneX simulator.

I have a viewcontroller without the statusbar. To do this I add:

- (BOOL)prefersStatusBarHidden {
    return YES;
}

It is good so far but the navigationbar overlaps the safearea in the iPhoneX.

enter image description here

How can I fix this?


Solution

  • Finally the solution was using safeAreaInsets

    if (@available(iOS 11.0, *)) {
            UIEdgeInsets safeInsets = UIApplication.sharedApplication.delegate.window.safeAreaInsets;
            paddingTop = safeInsets.top;
    }
    

    You can do this programatically or using autolayout

    enter image description here enter image description here