所以,我正在努力做到这一点:
我尝试在状态栏后面使用 UIView 并将颜色设置为橙色,但是运行时,UIView 显示在状态栏的正下方,所以它仍然是白色
我在互联网上尝试了很多解决方案,但没有一个有效。是的,它可以工作,但是当我移动到其他 View Controller 并再次返回时,颜色消失了。我应该怎么办?我正在使用 swift
最佳答案
UIApplication.shared.statusBarStyle = .lightContent
UINavigationBar.appearance().clipsToBounds = true
let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
statusBar.backgroundColor = UIColor.orange
尝试在您的 appDelegate 方法 application didFinishLaunchingWithOptions 中使用此代码
关于swift - 更改背景颜色状态栏 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37831114/