0

I bumped into an odd problem. Suddenly the color of my status bar does not change color to the same as my navigationbar in my tabbarcontroller.

enter image description here

I've tried setting the color of the navigationbar

self.navigationController!.navigationBar.barTintColor = UIColor(red: 57, green: 79, blue: 116)
        self.navigationController?.navigationBar.tintColor = UIColor.white
        self.navigationController?.navigationBar.isTranslucent = false
        self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]

But it just change the color of the navigationbar, not the statusbar. What am I missing?

Recusiwe
  • 1,594
  • 4
  • 31
  • 54

2 Answers2

0

create navigation controller in storyboard, tie it to controller and change the color of there. If it allows your project of course..

-1

Answer found here:

extension UIApplication {
    var statusBarView: UIView? {
        return value(forKey: "statusBar") as? UIView
    }
}

UIApplication.shared.statusBarView?.backgroundColor = .red
Jake
  • 2,126
  • 1
  • 10
  • 23
  • This is unnecessary and could stop working in a future iOS update or get your app rejected by Apple for digging into the private subview structure. There are countless apps that don't need code like this to get the status bar to show the correct color. – rmaddy Mar 02 '18 at 22:55