Several above solutions involve somewhat unnecessary use of NSStrings. This UIColor class extension is bit simpler & faster:
+ colorWithHex:(UInt32)hex alpha:(CGFloat)alpha
{
return [UIColor colorWithRed:((hex & 0xFF0000) >> 16)/255.0
green:((hex & 0x00FF00) >> 8)/255.0
blue:( hex & 0x0000FF)/255.0
alpha:alpha];
}
and to use it simply:
return [UIColor colorWithHex:0x006400 alpha:1.0]; // HTML darkgreen