jeshaitan
jeshaitan

Reputation: 301

Changing NavigationBar and System Colors Without Tint

Im trying to change the color of my navigation bar on every view controller of my app, but when I use the line: UINavigationBar.appearance().backgroundColor = UIColorFromHex(0xFF0000) (UIColorFromHex is my own custom function that does what it sounds like) in the AppDelegate.swift I get a weird gradient that changes from view to view: enter image description here enter image description here

I want a completely opaque red background, or any color for that matter, app-wide so it looks consistent. Help! Thanks!

Upvotes: 1

Views: 1764

Answers (1)

Nate Cook
Nate Cook

Reputation: 93296

Navigation bars are translucent by default, you need to turn that off, then use barTintColor to change the background of the navigation bar:

UINavigationBar.appearance().translucent = false
UINavigationBar.appearance().barTintColor = UIColor.redColor()

Setting the background color changes the semi-gross color underneath a translucent bar - you don't need that.

Upvotes: 9

Related Questions