Skip to content

Instantly share code, notes, and snippets.

@Neo-J
Created September 18, 2014 03:03
Show Gist options
  • Save Neo-J/98cccc385433256a699e to your computer and use it in GitHub Desktop.
Save Neo-J/98cccc385433256a699e to your computer and use it in GitHub Desktop.
WebColor to UIColor
+ (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