ios - iOS Swift 4 Status bar - disable Translucent
问题描述
I am trying to get the status bar of my iOS (webView) app not Translucent.
I tried this inside func viewDidLoad():
self.navigationController?.navigationBar.isTranslucent = false
And this in the appDelegate:
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().backgroundColor = .white
解决方案
Swift 5.1 iOS 13.0 Just in case for the current deprecations...
if #available(iOS 13.0, *) {
let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
let statusBarFrame = window?.windowScene?.statusBarManager?.statusBarFrame
let statusBarView = UIView(frame: statusBarFrame!)
self.view.addSubview(statusBarView)
statusBarView.backgroundColor = .green
} else {
//Below iOS13
let statusBarFrame = UIApplication.shared.statusBarFrame
let statusBarView = UIView(frame: statusBarFrame)
self.view.addSubview(statusBarView)
statusBarView.backgroundColor = .green
}
推荐阅读
- python - 使用旧字典中长度最长的键和值制作新字典,如何同时增加变量?
- javascript - 将数据传递给 Electron 中的模态
- javascript - 为什么 redux-form 不将选项字段中的值作为提交函数中的 prop 传递?
- laravel - VueJs | 拉拉维尔 | Vuejs函数在循环中不起作用
- javascript - Leaflet R中的不同颜色addPolylines
- java - 将我的应用程序连接到 SQLite 数据库 - 如何?
- html - HTML5 Canvas DrawImage Safari 12.0 错误(在 iOS 12.1/Mac OS Mojave 上测试)
- c# - 从 lambda 返回数组索引但抛出 IndexOutOfRangeException
- c - strcmp() 没有返回它应该返回的内容
- angular - Angular 2 Firebase如何在对象中获取数组