Skip to content

Instantly share code, notes, and snippets.

@shinyzhu
Created July 25, 2012 08:27
Show Gist options
  • Save shinyzhu/3175082 to your computer and use it in GitHub Desktop.
Save shinyzhu/3175082 to your computer and use it in GitHub Desktop.
UIColor from hex value in Objective-C
/*
UIColor from hex value in Objective-C
*/
#define UIColorFromRGB(rgbHex) [UIColor colorWithRed:((float)((rgbHex & 0xFF0000) >> 16))/255.0 green:((float)((rgbHex & 0xFF00) >> 8))/255.0 blue:((float)(rgbHex & 0xFF))/255.0 alpha:1.0]
// Usage:
UIColor *bgColor = UIColorFromRGB(0xCCEEFF);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment