更改状态栏的颜色 [英] Changing the Color of the Status Bar
本文介绍了更改状态栏的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将状态栏的颜色更改为蓝色或其他颜色。
I am trying to change the color of the status bar to like a blue, or some other color.
这是可能的,还是Apple不允许这样做?
Is this possible, or does Apple not allow it?
推荐答案
首先在Plist中设置查看基于控制器的状态栏外观
到否
First in Plist set View controller-based status bar appearance
to NO
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
if statusBar.responds(to:#selector(setter: UIView.backgroundColor)) {
statusBar.backgroundColor = UIColor.blue
}
UIApplication.shared.statusBarStyle = .lightContent
return true
}
输出截图如下
这篇关于更改状态栏的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文