Hex/HTML Color (RGBA, RGB) to UIColor
#define HEXCOLOR(c) [UIColor colorWithRed:((c>>24)&0xFF)/255.0 \
green:((c>>16)&0xFF)/255.0 \
blue:((c>>8)&0xFF)/255.0 \
alpha:((c)&0xFF)/255.0]
Usage: UIColor *c = HEXCOLOR(0xff0000);
.
If you want a macro for RGB (above is for RGBA), replace alpha: with alpha:1.0
.
Courtesy of this thread.
Comments
by Richard on 2009-06-18 18:40:23
by Idden on 2009-06-19 10:58:00
by Carlos Santos on 2011-12-19 22:02:34