Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bananafish911/90adc7e379fa804305ca2a57cd5b03e4 to your computer and use it in GitHub Desktop.
Save bananafish911/90adc7e379fa804305ca2a57cd5b03e4 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