I am running into an issue. I want the whole navigation bar (including safe area) color to change but the safe area color doesnt change at all (no matter what changes I make to it).
Heres
navigationController?.navigationBar.isTranslucent = false
navigationController?.navigationBar.backgroundColor = .green
navigationItem.titleView = searchBar
I even tried changing the Nav Bar's:
with no luck.
Current Navigation Bar Color
This view controller is being presented from the Scene Delegate using a navigation controller.
Let me know if you need any additional information.
Try this in your SceneDelegate
if #available(iOS 15, *) {
let navigationBarAppearance = UINavigationBarAppearance()
navigationBarAppearance.configureWithOpaqueBackground()
navigationBarAppearance.titleTextAttributes = [
NSAttributedString.Key.foregroundColor : UIColor.white
]
navigationBarAppearance.shadowColor = nil
navigationBarAppearance.backgroundColor = .green
UINavigationBar.appearance().barStyle = .green
UINavigationBar.appearance().standardAppearance = navigationBarAppearance
UINavigationBar.appearance().compactAppearance = navigationBarAppearance
UINavigationBar.appearance().scrollEdgeAppearance = navigationBarAppearance
}
Found a solution:
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .green
navigationController?.navigationBar.standardAppearance = appearance
navigationController?.navigationBar.scrollEdgeAppearance = navigationController?.navigationBar.standardAppearance
navigationItem.titleView = searchBar
I entered this in the function where I was configuring the navigation bar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.