Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8: Interface builder shows different color that set

Take a look at the picture below:

enter image description here

This is the same hex used in both places #28647B. The lower part is set from code and appears to reflects the color properly:

let proxy = UIPageControl.appearance()
proxy.pageIndicatorTintColor = UIColor.lightGray.withAlphaComponent(0.6)
proxy.currentPageIndicatorTintColor = UIColor.white
proxy.backgroundColor = UIColor(red: 40.0/255.0, green: 100.0/255.0, blue: 123.0/255.0, alpha: 1.0)

The upper part is set in interface builder.

I checked all other layers, opacity parameters etc and found nothing that can change the way this color look.

Now interesting part, I inspected both colors using HexColor mac app, this is the result:

for upper part:

enter image description here

Not sure what does it mean that RGB factors vary from the correct ones, but result is correct

Now, time to inspect the lower part:

enter image description here

This time RGB looks good but results is different.

Now it's the best part:

When I set the background color from code as I did in appearance proxy, it works fine. Is something interface builder speciffic that changes the visible shade of background color? How can one rely on colors set in Interface Builder?

like image 481
theDC Avatar asked Oct 03 '16 10:10

theDC


2 Answers

Same problem in my projects, I solved this issue choosing "Device RGB" and not "Generic RGB". Some. time the color not change , move opacity and the color will set. see the image:

enter image description here

like image 107
Scinfu Avatar answered Sep 30 '22 09:09

Scinfu


If you make an Asset Catalog, and add your colours in there, you can enter them as.

Devices: Universal Content: sRGB Input Method: 8-bit Hexadecimal

Add all your app colours in this way, and reference them by their Asset Catalog names, and all Hex Values will be preserved and displayed correctly.

like image 37
Mike Irving Avatar answered Sep 30 '22 09:09

Mike Irving