Skip to content

Instantly share code, notes, and snippets.

@jamztang
Forked from dstnbrkr/UIColorFromRGB
Created May 7, 2012 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jamztang/2628203 to your computer and use it in GitHub Desktop.
Save jamztang/2628203 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