Return to Snippet

Revision: 24258
at February 24, 2010 11:35 by espinallab

Initial Code
//If you come from a web development background, you're probably more used to hex color //strings. Put this macro at the top of your .m file, after the imports

#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

//Now you can simply write
cell.textColor = UIColorFromRGB(0xFF3366);

Initial URL

Initial Description
This is exactly what I was looking for since I come from web development

Initial Title
Transform hex color to objective-c color.

Initial Tags

Initial Language
Objective C