Created
February 8, 2013 16:56
-
-
Save jcromartie/4740350 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @implementation UIColor (strings) | |
| + (UIColor *)colorFromRGBHexString:(NSString *)colorString | |
| { | |
| if (colorString.length == 7) { | |
| const char *colorUTF8String = [colorString UTF8String]; | |
| int r, g, b; | |
| sscanf(colorUTF8String, "#%2x%2x%2x", &r, &g, &b); | |
| return [UIColor colorWithRed:(r / 255.0) green:(g / 255.0) blue:(b / 255.0) alpha:1.0]; | |
| } | |
| return nil; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment