When I use this:
UINavigationBar.appearance().backgroundColor = UIColor(named: "brown")
I get a nav bar that has the correct brown and it is translucent.
But I don't want it to be translucent, I just want it to be my brown color. So, I add another line of code to change the appearance to turn off the translucency, and instead of getting a solid brown, it just gives me the default white.
UINavigationBar.appearance().backgroundColor = UIColor(named: "brown")
UINavigationBar.appearance().isTranslucent = false
What am I doing wrong?
You're barking up the wrong tree completely. Leave isTranslucent
alone! Do not set any navigation bar properties directly! Use UINavigationBarAppearance to perform your configuration. For example:
let app = UINavigationBarAppearance()
app.configureWithOpaqueBackground()
app.backgroundColor = .brown
UINavigationBar.appearance().standardAppearance = app
UINavigationBar.appearance().scrollEdgeAppearance = app