【发布时间】:2020-06-16 13:49:07
【问题描述】:
我一直在尝试更改状态栏颜色,但使用 key statusBar 我的应用程序崩溃了。 我猜 iOS 13 中没有键“statusBar”。
let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
if statusBar.responds(to: #selector(setter: UIView.backgroundColor)) {
statusBar.backgroundColor = <Some Color>
}
添加视图也不适合我。
【问题讨论】:
-
请分享控制台日志并注明崩溃原因。
-
@DharmeshKheni 发生此崩溃:*** 断言失败 -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:],*** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“应用程序调用 - UIApplication 上的 statusBar 或 -statusBarWindow:此代码必须更改,因为不再有状态栏或状态栏窗口。在窗口场景中使用 statusBarManager 对象。'