Skip to content

Instantly share code, notes, and snippets.

@jdcrensh
Created July 1, 2010 03:11
Show Gist options
  • Save jdcrensh/459508 to your computer and use it in GitHub Desktop.
Save jdcrensh/459508 to your computer and use it in GitHub Desktop.
Extends UIColor for hex color values
@interface UIColor (Hex)
+ (UIColor *)colorWithHex:(uint)rgbValue;
@end
@implementation UIColor (Hex)
+ (UIColor *)colorWithHex:(uint)rgbValue {
float redValue = ((rgbValue & 0xFF0000) >> 16) / 255.0;
float greenValue = ((rgbValue & 0xFF00) >> 8) / 255.0;
float blueValue = (rgbValue & 0xFF) / 255.0;
return [UIColor colorWithRed:redValue green:greenValue blue:blueValue alpha:1.0];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment