Skip to content

Instantly share code, notes, and snippets.

@fwhenin fwhenin/HexUIColor.m
Created May 14, 2014

What would you like to do?
Hex to UIColor Method
+(UIColor *)convertToUIColorFromHex:(NSString *) hex{
NSScanner *scanner = [NSScanner scannerWithString:hex];
unsigned int baseColor;
[scanner scanHexInt:&baseColor];
CGFloat red = ((baseColor & 0xFF0000) >> 16) / 255.0f;
CGFloat green = (baseColor & 0x00FF00) >> 8) / 255.0f;
CGFloat blue = (baseColor & 0x0000FF)) / 255.0f;
UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:1.0f];
return color;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.