如何设置状态栏的颜色,在顶部显示载具,时间和电池 [英] How to set color of status bar showing carrier, time, and battery on top
问题描述
我有一个ViewController,它是第一个要加载的,并且我不使用NavigationController导航到下一个VC.我使用Segue.
I have a ViewController which is the 1st to be loaded and I don't use the NavigationController to navigate to the next VC. I use Segue.
我有一张背景图片,涵盖了此第一个VC的整个屏幕. 它涵盖了运营商/时间/电池"的状态栏,颜色变为黑色.用户将看不到电池寿命.
I have a background image which covers the entire screen for this 1st VC. It covers the status bar for Carrier/Time/Battery and the color turn black. User will not able to see the battery life.
我的项目info.plist文件中没有基于视图控制器的状态栏属性(将其设置为NO)
There is no view controller-based status bar property in my project info.plist file(In setting it to NO)
我该怎么做才能将颜色设置为白色或其他颜色,以使状态栏可见?
What do I need to do to set the color white or another color to make the staus bar visible?
override func viewWillAppear() {
super.viewWillAppear()
var nav = self.navigationController?.navigationBar
nav?.barStyle = UIBarStyle.Black
nav?.tintColor = UIColor.whiteColor()
nav?.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orangeColor()]
}
推荐答案
您可以override
将preferredStatusBarStyle
更改为.lightContent
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
这篇关于如何设置状态栏的颜色,在顶部显示载具,时间和电池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!