iPhone X上的警报显示UIAlertController弹出窗口的不同颜色

时间:2017-12-17 23:08:05

标签: ios swift xcode iphone-x

我有一个我最初在iOS 10的Xcode 8中构建的应用程序。我最近升级到 Xcode 9 并且已经为iPhone X和iOS 11修复了我的应用程序。我遇到很多问题的一个问题是如何制作整个屏幕(包括在提示警报时暗淡的区域。见图:

我在“连接”视图控制器上显示警报(您在下面看到)。我没有采取任何措施来操纵此View Controller的根视图。我在故事板中为此根视图“检查了”“安全区域相对边距”和“安全区域布局指南”。 (我也尝试过检查/不检查这些方框的所有其他排列,没有任何区别。)

有趣的是,当我在自己的iPhone 6上运行此版本时,状态栏也没有变暗(尽管由于状态栏在iPhone X之前很小,所以它不太明显)。这个问题肯定是在Xcode 9中开始的,因为我在App Store上的当前版本(使用Xcode 8构建)会在整个屏幕上显示警报。

有没有人对如何解决这个问题有任何想法?如果您需要其他信息,请与我们联系。

1 个答案:

答案 0 :(得分:0)

使用

更新 info.plist
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

使用将子视图添加到UIWindow as -

UIApplication.shared.statusBarStyle = .lightContent//for white color
let statusBarBgView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIApplication.shared.statusBarFrame.height))

statusBarBgView.backgroundColor = UIColor.red//status bar color
window?.rootViewController = MYViewController//Entry point 
window?.rootViewController?.view.addSubview(statusBarBgView)//Adding to window

带有提示弹出窗口的结果 - &gt;

enter image description here

结果与后台应用列表 - &gt;

enter image description here

相关问题