Sean Danzeiser
Sean Danzeiser

Reputation: 9243

Color from nib color picker is different then [UIColor -colorWithRed:green:blue:alpha:]

I've got a certain color that I'd like to use throughout my app. That color has got these RGBA values:

R:217 G:66 B:60 A:1.0

Now, in some nibs I'm using this color as a background color via the color picker. In other cases, I'm using this code to set colors manually

[UIColor colorWithRed:217.f/255.f green:66.f/255.f blue:60.f/255.f alpha:1.0f];

However, I am finding that the colors do not match visually!!

enter image description here

enter image description here What is going on? Why do the colors look so different?

Printing out the colors gives me this:

(lldb) po [self.programticLabel backgroundColor]
UIDeviceRGBColorSpace 0.85098 0.258824 0.235294 1

(lldb) po [self.nibLabel backgroundColor]
UIDeviceRGBColorSpace 0.805696 0.171843 0.181392 1

Upvotes: 1

Views: 736

Answers (1)

Sean Danzeiser
Sean Danzeiser

Reputation: 9243

Aha! The answer can be found here:

Weird colors in XCode Interface Builder?

If you go to the RGB color picker in Xcode - be sure to take note of the settings button to the right of the dropdown. RGB is defined as a part of a color space -- and mine was not set to Apple's.

Upvotes: 1

Related Questions