Markus G.
Markus G.

Reputation: 1718

RGB Color, wrong color

I am currently working on an iOS Application in Swift 3 and wanted to change the color of my NavigationBar with the following code:

self.navigationController?.navigationBar.barTintColor = UIColor.init(red: 53.0/255.0, green: 70.0/255.0, blue: 90.0/255.0, alpha: 1.0)

This code works quite fine but there's one problem. The color I entered in RGB format is displayed wrong.

Should be like this color: enter image description here

But looks like this (left: is current Color () right: as already said should look like):

enter image description here

Upvotes: 1

Views: 539

Answers (2)

Baig
Baig

Reputation: 4995

Change navigation bar to Opaque instead of Translucent.

Swift

self.navigationController?.navigationBar.isTranslucent = true

Objective-C

[[UINavigationBar appearance] setTranslucent:YES];

Please find in image.

enter image description here

And if you are setting navigations background color then change navigation background color instead of tint color.

Upvotes: 0

Aakash
Aakash

Reputation: 2269

Set navigationController?.navigationBar.isTranslucent = false.

You can also achieve this by unchecking Translucent from storyboard.

enter image description here

Upvotes: 3

Related Questions