Reputation: 5849
I have a Navigation Controller, where I am coloring my navigation bar with some color, and I want the status bar (which shows the carrier, wifi symbol, etc) to use the same color.
So in Info.plist
, I have set View controller-based status bar appearance equal
to NO
. And in the Target > Deployment Info
I set the Status Bar Style > Light
:
I can see that the status bar is now indeed using the "light" style as the text is light/white. But the status bar background is still not the same as the Navigation bar as seen below. How can I correct this?
Upvotes: 5
Views: 1721
Reputation: 7485
You have to use like this :
if let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as? UIView {
statusBar.backgroundColor = UIColor.purple
}
If you want to change the status bar color all over the app, use it in appdelegate->didFinishLaunchingWithOptions
. Or if you want to change for any particular screen, then call it in the particular viewDidLoad
.
Upvotes: 7