Skip to content

Instantly share code, notes, and snippets.

@AndyIbanez
Created January 19, 2014 19:25
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 AndyIbanez/8509793 to your computer and use it in GitHub Desktop.
Save AndyIbanez/8509793 to your computer and use it in GitHub Desktop.
Get a UIColor out of a Hex string representation.
//I did not write this macro. Got it from somewhere else years ago.
// example usage: [view setBackgroundColor:UIColorFromHex(0x6758c8)];
#define UIColorFromHex(hexValue) [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0 green:((float)((hexValue & 0xFF00) >> 8))/255.0 blue:((float)(hexValue & 0xFF))/255.0 alpha:1.0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment