\n","author":{"@type":"Person","name":"Halil İbrahim YÜCE"},"upvoteCount":2,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"
Try this
\n let navBarAppearance = UINavigationBarAppearance()\n navBarAppearance.configureWithOpaqueBackground()\n navBarAppearance.backgroundColor = UIColor.white\n\n UINavigationBar.appearance().standardAppearance = navBarAppearance\n
\n","author":{"@type":"Person","name":"Asperi"},"upvoteCount":1}}}Reputation: 169
I don't want transculent navigationbar in my app. So, I added this code to change it. It works but there is a little problem. If I use largeTitle navigation, status bar color is looks gray. How can I deal with it ? Thanks in advance.
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().barTintColor = UIColor.white
UINavigationBar.appearance().backgroundColor = UIColor.white
Upvotes: 2
Views: 6263
Reputation: 258441
Try this
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
navBarAppearance.backgroundColor = UIColor.white
UINavigationBar.appearance().standardAppearance = navBarAppearance
Upvotes: 1
Reputation: 16371
You could fix it by adding a subview on top of status-bar using UIStatusBarManager
.
if #available(iOS 13, *) {
let keyWindow = UIApplication.shared.connectedScenes
.filter({$0.activationState == .foregroundActive})
.map({$0 as? UIWindowScene})
.compactMap({$0})
.first?.windows
.filter({$0.isKeyWindow}).first
let statusBar = UIView(frame: (keyWindow?.windowScene?.statusBarManager?.statusBarFrame)!)
statusBar.backgroundColor = .white
keyWindow?.addSubview(statusBar)
}
Upvotes: 3