UIColor + Digital Color Meter

  • Twitter
  • Facebook
  • Digg
  • Reddit
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
April 11th, 2011 Posted by: (ELC) - posted under:Snippets

Hey iCoders,

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:

https://github.com/elc/UIColor-DigitalColorMeter

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

UPDATE:

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.

  • http://koyeung.pip.verisignlabs.com/ koyeung

    I like RainbowPicker ( http://www.setnan.org/mac/rainbowpicker/ ) . no category is needed

  • http://profiles.google.com/cruffenach Collin Ruffenach

    Great call. Rainbow Picker looks freaking great. Thanks!

  • 1_Soical_Media

    How do i use this color meter? can anyone tell me?

  • http://twitter.com/thomas_typo3 thomas_typo3

    Thanks for the tips! I didn’t know DigitalColor Meter and RainbowPicker. I use them both in combination now. ;-)

    ColorMeter for picking the color from the screen. Press ctrl+h to hold the color and than drag it to RainbowPicker to get the NSColor init code. That works perfectly and I don’t have to subclass UIColor in every project.

    First I had the same concerns as you, as RainbowPicker can’t actually pick an colors. But when I found out that I can drag and drop the color between the apps I certainly had the tool I was looking for since I started using colors in iOS.

    Greets,
    Thomas

  • http://vocaro.com/trevor/ Trevor

    Can’t you use the standard OS X color picker for this? When choosing a color, click the magnifying glass, then click anywhere on your screen and the color will be selected. You can then extract the values from the RGB slider.

  • Anonymous

     That’s really interesting and informative post. Thanks for sharing it iphone developer

  • Андрей Кулаковский

    thanks a lot your artocle is so important for me, i used some info at ставки на футбол  , when created it.

  • http://%/Endworld3 Alexander1

    buy@aloe.vera.gel” rel=”nofollow”>…

    Need cheap generic VIAGRA?…

  • Zotikrabota

    Very cool article learned many interesting things but this paper is better best protein shake 

blog comments powered by Disqus
canakkale canakkale canakkale balik tutma search canakkale vergi mevzuati