Reputation: 1055
I added navigationBar manualy from controls
How to make StatusBar Backgroud color = same as navigationBar
Upvotes: 1
Views: 2645
Reputation: 8986
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
Upvotes: 4