Skip to content

Instantly share code, notes, and snippets.

@onevcat
Forked from jamztang/UIColorFromHex.m
Created May 10, 2012 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onevcat/2650771 to your computer and use it in GitHub Desktop.
Save onevcat/2650771 to your computer and use it in GitHub Desktop.
Convert hex value to UIColor
UIColor* UIColorFromHex(NSInteger colorInHex) {
// colorInHex should be value like 0xFFFFFF
return [UIColor colorWithRed:((float) ((colorInHex & 0xFF0000) >> 16)) / 0xFF
green:((float) ((colorInHex & 0xFF00) >> 8)) / 0xFF
blue:((float) (colorInHex & 0xFF)) / 0xFF
alpha:1.0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment