Last active
December 15, 2015 13:19
-
-
Save ralfebert/5266154 to your computer and use it in GitHub Desktop.
See http://www.ralfebert.de/snippets/ios-swift/uicolor/ for the Swift version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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