如何设置状态栏的颜色,在顶部显示载具,时间和电池 [英] How to set color of status bar showing carrier, time, and battery on top

查看:172
本文介绍了如何设置状态栏的颜色,在顶部显示载具,时间和电池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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()]
}

推荐答案

您可以overridepreferredStatusBarStyle更改为.lightContent

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

这篇关于如何设置状态栏的颜色,在顶部显示载具,时间和电池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆