Skip to content

Instantly share code, notes, and snippets.

@Joony
Created March 1, 2012 09:27
Show Gist options
  • Save Joony/1948537 to your computer and use it in GitHub Desktop.
Save Joony/1948537 to your computer and use it in GitHub Desktop.
On Objective-C Macro for converting Hex values (or any number) to a UIColor object.
#define UIColorFromRGBA(rgbaValue) [UIColor colorWithRed:((float)((rgbaValue & 0xFF0000) >> 16)) / 255.0 \
green:((float)((rgbaValue & 0xFF00) >> 8)) / 255.0 \
blue:((float)(rgbaValue & 0xFF)) / 255.0 \
alpha:((float)((rgbaValue & 0xFF000000) >> 24)) / 255.0]
UIColor *color = UIColorFromRGBA(0xFFFFFFFF);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment