Created
September 18, 2014 03:03
-
-
Save Neo-J/98cccc385433256a699e to your computer and use it in GitHub Desktop.
WebColor to UIColor
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
+ (UIColor *)colorFromHexString:(NSString *)hexString { | |
unsigned rgbValue = 0; | |
NSScanner *scanner = [NSScannerscannerWithString:hexString]; | |
[scanner setScanLocation:1];// bypass '#' character | |
[scannerscanHexInt:&rgbValue]; | |
return [UIColorcolorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment