2017-09-27 39 views
1

我在iPhone11模擬器中遇到了iOS11問題。沒有狀態欄的NavigationBar與iOS11中的safearea重疊

我有一個viewcontroller沒有狀態欄。要做到這一點,我補充說:

- (BOOL)prefersStatusBarHidden { 
    return YES; 
} 

這是迄今爲止,但導航欄重疊在iPhoneX safearea。

enter image description here

我該如何解決這個問題?

+0

是你的導航欄標準UINavigationBar的或定製的解決方案? –

+0

我的導航欄是標準@CalStephens –

+0

嗨,我的全屏應用程序也使用導航控制器,我也遇到同樣的問題。你設法解決它嗎? –

回答

5

最後的解決方案是使用safeAreaInsets

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

您可以通過編程做到這一點,或使用自動佈局

enter image description hereenter image description here