【发布时间】:2019-10-17 10:05:48
【问题描述】:
我在我的应用中添加了第二个窗口,用于在用户点击远程推送通知时显示特定控制器。
func navigateThroughPushnotification(controller: UINavigationController) {
let window = UIWindow(frame: UIScreen.main.bounds)
let vc = UIViewController()
vc.view.backgroundColor = .clear
window.rootViewController = vc
window.windowLevel = UIWindow.Level.alert + 1
window.makeKeyAndVisible()
if let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView {
statusBar.backgroundColor = kAppDefaultColor
}
vc.present(controller, animated: true, completion: nil)
}
问题是我也想更改此窗口的状态栏颜色,但我用来更改主窗口颜色的代码这次不起作用。
guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return true }
statusBar.backgroundColor = kAppDefaultColor
现在这段代码在主窗口中运行得很好。 请有人帮助检测应该做些什么来改变第二个窗口的颜色。 提前致谢
【问题讨论】:
-
你想改变整个应用程序状态栏的颜色吗?
-
@BhumeshPurohit 我已经在整个应用程序中更改状态栏颜色,但是在这种情况下创建另一个窗口时会失败
标签: ios swift uistatusbar