NavigationBar without statusbar overlaps safearea in iOS11

倖福魔咒の 提交于 2020-01-24 22:06:08

问题


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.

How can I fix this?


回答1:


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



来源:https://stackoverflow.com/questions/46453758/navigationbar-without-statusbar-overlaps-safearea-in-ios11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!