ios - XCode11,iOS如何设置statusBar背景色
问题描述
如何更改 Swift 以设置 StatusBar 背景颜色?
在此代码预期工作之前。
func setStatusBarStyle(_ style: UIStatusBarStyle, backgroundColor:UIColor = .clear) {
if let statusBar = UIApplication.shared.value(forKey: "statusBar") as? UIView {
statusBar.backgroundColor = backgroundColor
statusBar.setValue(style == .lightContent ? UIColor.white : .black, forKey: "foregroundColor")
}
}
现在使用 Xcode11 我得到编译致命错误:
*** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“在 UIApplication 上调用 -statusBar 或 -statusBarWindow 的应用程序:必须更改此代码,因为不再有状态栏或状态栏窗口。在窗口场景中使用 statusBarManager 对象。
任何想法将不胜感激
解决方案
推荐阅读
- node.js - 如果在passport-facebook节点js的数据库中找不到用户,则重定向到注册页面
- javascript - 从哪里获得 Paytm CSRF 令牌
- javascript - JSON对象名称未定义,如何访问参数?
- react-native - react-native-fast-image 是否会缓存在 src 中使用 require 加载的图像
- shopware - 商店软件登录不起作用,那么实际问题是什么?
- javascript - 画布 - 在 Firefox 中剪辑图像并使用复合操作“乘法”不像在 Chrome 中那样工作
- ios - 如何为其他开发者提供 App 名称?
- javascript - 基于键及其值的 GroupBy 数组
- python - 使用 matplotlib 绘制分类数据 - 转置 pandas 数据框
- docker - 如何与 kubernetes 集群共享我的谷歌云实例的卷