5

I've been using a color that I chose with a color picker in Xcode. I need to use that color programmatically now, but I don't know its hex code.

Is there a way to see it in Xcode?

I'm using Xcode 4.2.

Louis Waweru
  • 3,572
  • 10
  • 38
  • 53

4 Answers4

15

As of Xcode 6, users can view both RGB, CMYK, HSB and the Hex value as shown below. (No need for conversion)

enter image description here

4aRk Kn1gh7
  • 4,259
  • 1
  • 30
  • 41
  • This answer is correct but it is worth noting that colour values must be set to 8 bit (0-255) in order to see the hex value. The hex value will not appear if colour value is set to float (0.0-1.0) – arcady bob Dec 07 '16 at 23:15
  • @arcadybob well if the values are in float then just multiple them with 255 (denormalize) and then you can find the hex value by using the above method. – 4aRk Kn1gh7 Dec 08 '16 at 10:54
11

Assuming you are talking about picking color in xcode interface builder, the answer can be obtained in 2 steps:

Step 1: Get RGB values by following this link.

Step 2: Convert that to hex code by following this link

Community
  • 1
  • 1
Saran
  • 6,274
  • 3
  • 39
  • 48
3

write this in .m file

1.NSLog(@"color is %@",picker.color);

Tendulkar
  • 5,550
  • 2
  • 27
  • 53
  • Hi, Hitman. I could have been more clear. I used the color picker to set a color for a button's title text. I tried your idea like: `NSLog(@"color:%@",[myButton titleColorForState:UIControlStateNormal]);` but got these values: `color:UIDeviceRGBColorSpace 0.196078 0.309804 0.521569 1`. I guess the 1 is the alpha channel, but I'm not sure what to do with the RGB values. – Louis Waweru Nov 01 '11 at 13:36
  • [UIColor colorwithRed :blue ]//some function is there.use that – Tendulkar Nov 01 '11 at 13:49
  • Thank you. It's `[UIColor colorWithRed: green: blue: alpha: ]`. – Louis Waweru Nov 01 '11 at 15:22
1

ColorSense is a very simple xcode extension that makes it easy to do exactly what you needed.

Use as below:

enter image description here enter image description here

Watch the short video here to see how it works.

You can download the extension here

Wesley Smith
  • 19,401
  • 22
  • 85
  • 133