作者:longfeiPHP | 来源:互联网 | 2023-01-16 14:02
iOS11中有一个iPhoneX模拟器有问题.
我有一个没有状态栏的viewcontroller.要做到这一点,我添加:
- (BOOL)prefersStatusBarHidden {
return YES;
}
到目前为止它还不错,但导航栏与iPhoneX中的safearea重叠.
![在此输入图像描述](https://img.php1.cn/3cd4a/1eebe/cd5/b428d8f746fb8d47.webp)
我怎样才能解决这个问题?
1> Pablo Martin..:
最后解决方案正在使用 safeAreaInsets
if (@available(iOS 11.0, *)) {
UIEdgeInsets safeInsets = UIApplication.sharedApplication.delegate.window.safeAreaInsets;
paddingTop = safeInsets.top;
}
您可以以编程方式或使用autolayout执行此操作
![在此输入图像描述](https://img.php1.cn/3cd4a/1eebe/cd5/8be1ccb5166feb93.webp)