views:

288

answers:

5

How can I enter RGB or Hex color values for backgrounds in Interface Builder? I can select predefined colors but I would like to manually enter in RGB values. Where can I do this?

A: 

http://adeem.me/blog/wp-content/uploads/2009/iPhoneDevelopment/GettingStarted/Picture%2017.png

Check the above snap, in that go to Colors Tray, select the second button(RGB sliders(rectangle image) - which is placed next to circle on the top of the tray). In that you can enter RGB values.

Chandan Shetty SP
+4  A: 

How to choose a color by RGB in Interface Builder.

Click on the color slider icon, and then choose "RGB Sliders" from the drop-down list.

You can also use the magnifying-glass as a color picker to pick up an exact color from anywhere on the screen.

Tyler
Thanks for the tip! Random question, what software did you use to write over that screenshot? Nice addition.
Sheehan Alam
Actually, be careful with the magnifying glass. Just component numbers do not spec a color, you also need to know the colorspace. It's like string encodings. 65 is the ASCII encoding of A. The colorspace with which to encode/decode the components is in the little dropdown to the left of "RGB" sliders above. The "Generic RGB" colorspace corresponds to colors made with +[NSColor colorWithCalibratedRed:green:blue:alpha:]. If you use the magnifying glass, the components will be given with respect to "device" space which means the current screen. This is not appropriate. Select generic after.
Ken
Oops, this question is for the iPhone. The iPhone isn't colormatched. sRGB is probably the best approximation of its screen, so if you want to have component numbers appropriate for use with UIColor, select sRGB as the colorspace.
Ken
I used a Wacom Bamboo Fun writing tablet to write on the screenshot in Photoshop (Gimp works just as well for this). Took the screenshot with command-shift-4, then space and clicked on the window.
Tyler
Has anyone experienced this: When I try to move the color sliders... they just pop back to their old position. (Everything works find if I type the values in directly, though.)
Bonnie
I can't reproduce that behavior, Bonnie, although I've tried. I'm running IB 3.2.2. As a guess of how to deal with it, you could try just clicking directly on the destination point in the slider, instead of dragging.
Tyler
A: 

It sounds like you're unfamiliar with the Mac OS X color panel. Click the tabs along the top of the color panel window to choose other pickers. Pickers are also plugins, so it's possible to add new UI for color selection. See, for example, developer color picker.

Ken
A: 

I use this color picker to convert colors to NSColor/UIColor:

http://www.panic.com/~wade/picker/

christo16
A: 

Is there a place to enter the alpha value also in interface builder?

pkaur