I'm developing a notes application and I want the colors of the notes to match the color of the Navigation Bar. When I set the color of the Navigation Bar, the color appears only when I scroll the screen. I want the color to show up without scrolling the screen.
I use a Xcode 14 and Swift 5
I tried navigationController?.navigationBar.barTintColor = UIColor.flatSkyBlue()
AND navigationController?.navigationBar.backgroundColor = UIColor.flatSkyBlue()
but it didn't work.
Thank you for help.
Try to configure your navBar like this, in viewDidLoad declare UINavigationBarAppearance and set navigation bar:
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
navBarAppearance.backgroundColor = UIColor.red // set your bg color
navigationController?.navigationBar.standardAppearance = navBarAppearance
navigationController?.navigationBar.compactAppearance = navBarAppearance
navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
navigationController?.navigationBar.prefersLargeTitles = true // false if you don't want large title
navigationController?.navigationBar.tintColor = .white
navigationItem.title = "title"