Short post today on a little tool I made for myself that is turning out to be very useful. This is a simple UIColor category which adds a class level initializer that accepts the color strings output from the Digital Color Meter application in OS X. I regularly make iOS apps which refer to design PDF documents. Many times designers don’t provide exact details to what colors are in the design. To get them I use the Digial Color Meter application located in
Macintosh HD/Applications/Utilities/Digital Color Meter.app
Make sure the meter is set to show “RGB as percentage”. With this done, get your cursor over the color you want and hit “Command + Shift + C”. This will copy a string of the values to your clipboard. You can pass this string into the initializer and a UIColor object of that color will be returned. A simple example is provided in the sample application. You can find the project on github at:
Hope this saves some of you a few minutes when creating colors from a mock given to you by a designer. Happy coding.
Follow me on Twitter @cruffenach
Commenter koyeung pointed out a great little app called Rainbow Picker. This app does do some cool stuff in terms of pre formatting the code to make UIColor and NSColor objects. However the real advantage of using Digital Color Meter is the ability to get the color of any pixel on your screen. My main use case is taking a mock up PDF of an interface and turning that into actual code. For this task Rainbow Picker won’t do the job and I’m sticking with Digital Color Meter. Here is a screen shot of digital color meter giving me the color of the color value text it displays.