Xcode - Colours look different but should be the same

900 views Asked by At

In my app, I am using the following color: #3D6D86

It is set to be a background color on a view controller and also to be the color for the navigation bar on a different view controller. However the problem is that the color appears different. I converted the hex to the correct type of UIColor notation for use with swift so I can't see the issue being there either. I will attach some screenshots below to show you what I mean:

enter image description here enter image description here

-----------EDIT-----------

Now when I use this code to try and remove translucency: UINavigationBar.appearance().translucent = false UINavigationBar.appearance().barTintColor = UIColor(red:0.24, green:0.43, blue:0.53, alpha:1.0)

I am left with a white gap between the navigation bar and the image which should be below it. Any ideas?

2

There are 2 answers

3
johnpatrickmorgan On BEST ANSWER

Because of the blurring effect on a translucent UINavigationBar, the color you set is not exactly how it will be displayed on screen. You can either set your navigation bar's translucent property to NO:

self.navigationController.navigationBar.translucent = NO;

... or use this handy calculator to work out the correct input color to get your desired color on-screen:

0
MGY On

To fix this you can set navigationbar's translucent in viewDidLoad :

[self.navigationController.navigationBar setTranslucent:NO];