Skip to content

Instantly share code, notes, and snippets.

@ralfebert
Last active December 15, 2015 13:19
Show Gist options
  • Save ralfebert/5266154 to your computer and use it in GitHub Desktop.
Save ralfebert/5266154 to your computer and use it in GitHub Desktop.
// For example:
// UIColorFromRGBA(0xffee00, 0.5)
// UIColorFromRGB(0xffee00)
static inline UIColor *UIColorFromRGBA(int rgb, float a) {
return [UIColor colorWithRed:((float)((rgb & 0xFF0000) >> 16))/255.0
green:((float)((rgb & 0xFF00) >> 8))/255.0
blue:((float)(rgb & 0xFF))/255.0 alpha:a];
}
static inline UIColor *UIColorFromRGB(int rgb) {
return UIColorFromRGBA(rgb, 1.f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment