24

I have an UIImageView with a brown image that will not always reach the top part. The UIImage view is inside a white UIView.

So, because the top part of the image is a linear brown color, I said I will make the UIView underneath it the same brown color, and the user will not see where the image ends. So far, so good.

My problem is, when I pick the color in the top part of the image, the color picker picks a more darker color than actually is there :(

Before I click the color picker: enter image description here

After I click the color picker: enter image description here

How comes ?

Nicu Surdu
  • 8,172
  • 9
  • 68
  • 108

6 Answers6

32

Just wanted to elaborate upon the accepted answer with some screenshots.

If you want to match RGB values between Photoshop and Xcode exactly (without conversion between colorspaces) then you need to save your images in generic RGB and enter any dropper values using the generic RGB colorspace.

  • When you choose "Save for Web & Devices" from Photoshop, uncheck the "Convert to sRGB" box.

enter image description here

  • In Xcode, click the colorspace popup in the color picker and choose "Generic RGB", then enter the red, green and blue values from Photoshop, NOT THE HEX VALUE as this reverts back to the sRGB colorspace for some reason (be careful not to tab to the hex field either, as that also changes the colorspace to sRGB).

enter image description here

More info here, including how to match screenshots.

Community
  • 1
  • 1
Zack Morris
  • 4,727
  • 2
  • 55
  • 83
14

I've managed to find out a solution/explanation (tho I'm still confused) in this answer: https://stackoverflow.com/a/9203647/460750

Basically, what I did to solve my issues, was to choose from the RGB "types" select (that little square under the color picker) the Apple RGB option, and enter the R, G and B values manually, instead of using the picker.

Odd...

Community
  • 1
  • 1
Nicu Surdu
  • 8,172
  • 9
  • 68
  • 108
  • 8
    Thanks, but instead of using `Apple RGB`, I used `Generic RGB`. This gave me more accurate colors. You can test this by dropping in a sample image with true colors into an imageview to compare against the colors. – ninjaneer Jun 21 '13 at 09:10
2

Its because the component numbers don’t spec a color. We also need to know the color space which xCode uses. Colorspace which encodes or decodes is available in the drop down left to the RGB slider.

enter image description here

By default xCode chooses the "Generic RGB" and that is what UIColor uses spec color from RGB. If we use magnifying glass, it will change to "Device RGB” space and that is based on your current screen. So “sRGB" or "Adobe RGB" would be the better or close to what you want if you are using the magnifying glass to pick a color.

Nicu Surdu
  • 8,172
  • 9
  • 68
  • 108
Krishna Kishore
  • 924
  • 8
  • 4
1

I think Generic RGB also works. the trick is you need to enter number of R G B manually after change the RGB mode in dropdown list

Odd... (too)

saranpol
  • 2,177
  • 1
  • 23
  • 22
  • I'm pretty sure I've tried that, in my desperation, but it didn't work. When I'll have the chance, I'll try it again to check. Thank you for your input ;) – Nicu Surdu Jan 06 '13 at 03:31
  • Same here. You should send them back another email. Tell them that 2 other people are having the same issue. – Anthony Flores Oct 08 '15 at 19:45
0

UPDATE 10.10.4

I had this issue as well, I reported it to Apple, and it seems to have been solved on 10.10.4 (it was related to the color picker itself, not to Xcode/IB)

Can someone else confirm it?

Alessandro Orrù
  • 3,443
  • 20
  • 24
  • 1
    I'm still seeing the same issue when using the Color Picker on 10.10.4. Set the background color of a View to HEX #456456. Run the simulator. Open the color picker, click the view with #456456, and you get a different value. – Dave Aug 04 '15 at 01:22
0

This is an old question, but it was important for me to add some info. The only method that has been working for me accurately over the years was to not use PS's Color Picker, but use macOS' built-in "Digital Color Meter".

enter image description here

It's bundled with every installation of macOS and the RGB values emitted from there with "Generic RGB" always reproduce the correct color in Xcode Storyboards.

enter image description here

Shai Mishali
  • 9,224
  • 4
  • 56
  • 83