Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set color of status bar showing carrier, time, and battery on top

Tags:

ios

swift

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.

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.

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()]
}
like image 423
MilkBottle Avatar asked May 30 '15 15:05

MilkBottle


1 Answers

You can override the preferredStatusBarStyle to .lightContent

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}
like image 155
Leo Dabus Avatar answered Oct 12 '22 04:10

Leo Dabus