1

I added navigationBar manualy from controls enter image description here

How to make StatusBar Backgroud color = same as navigationBar

enter image description here

OuSS
  • 1,047
  • 1
  • 15
  • 23
  • This should help you http://stackoverflow.com/a/39802582/5327882 – ronatory Nov 12 '16 at 13:49
  • Possible duplicate of [Change Status Bar Background Color in Swift 3](http://stackoverflow.com/questions/39802420/change-status-bar-background-color-in-swift-3) – Keiwan Nov 12 '16 at 13:49
  • and how to back to default when view disappear ?? – OuSS Nov 12 '16 at 13:55
  • Is not possible to link status with navigationBar whitout changing backgroud color of status like we do for UINavigationController ? – OuSS Nov 12 '16 at 13:58

1 Answers1

4

Try this code: Tested in Swift 3

@IBOutlet weak var navBar: UINavigationBar!

override func viewDidLoad() {
    super.viewDidLoad()

    navBar.barTintColor = UIColor.black // Set any colour 
    navBar.isTranslucent = false

    navBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white, NSFontAttributeName:UIFont(name:"HelveticaNeue", size: 16)!]

    let barView = UIView(frame: CGRect(x:0, y:0, width:view.frame.width, height:UIApplication.shared.statusBarFrame.height))
    barView.backgroundColor = UIColor.black
    view.addSubview(barView)
}

override var preferredStatusBarStyle: UIStatusBarStyle {

    return .lightContent
}

Updated to clear down voters

enter image description here

Joe
  • 8,868
  • 8
  • 37
  • 59