Wednesday, December 8, 2010

Convert Hex colors into UIColor easily


When you receive a Photoshop file with the latest design for the iPhone app you’re working on, it’s sometimes a real challenge to put everything the designer came up into standard (and custom) iPhone UI. One thing that might help you speed up a bit the process is this web tool which takes a Hex color and produces the Objective-C code to initialize a UIColor instance.
Now I know there are several Objective-C categories out there to add support for hex colors to UIColor, but it looks to me like a huge overkill to run 3 times NSScanner trough a text string to initialize a UIColor, and that UIColor value is always the same until at least the next app update. If you get my drift there’s no sense to calculate every time a value which never changes.
Say you’ve got some PSD and you’re using the Eyedropper tool to take sample of a color :

Once you copy the HEX value from the dialogue you put it in the color convertor tool press “Convert now” and you get the code for your source file:

Now, I hope it’ll be useful to everybody, if you have any thoughts about the color converter please do leave me a message
Best, Marin
Go to the color converter now

No comments:

Post a Comment

Followers