0

My UED tell me the color must be #595959 and #333333.

But which delegate method I should use in UIColor to get the color with strings above?

Anyone?

Thank you .

generalzyq
  • 303
  • 3
  • 11
  • This link have what you need http://stackoverflow.com/questions/3805177/how-to-convert-hex-rgb-color-codes-to-uicolor – Doan Cuong Sep 12 '12 at 08:01
  • hi Actually, the former tow number, the middle two number and the last two number means the hex number of the color. And you can use method RGBCOLOR(); to get the color. This is a easy way. – generalzyq Sep 12 '12 at 08:15

1 Answers1

0
@implementation UIColor (Hex) 

+ (UIColor *)colorWithHex:(NSUInteger)hex // accepts values like 0x556677
{
    CGFloat colors[3];

    for(int i=0; i<3; ++i) {
        NSUInteger val = hex & 0xFF;
        colors[i] = (CGFloat)val/255.0f;
        hex >>= 8;
    }
    return [UIColor colorWithRed:colors[2] green:colors[1] blue:colors[0] alpha:1.0f];
}

@end

David H
  • 40,852
  • 12
  • 92
  • 138