Created
April 21, 2017 22:36
-
-
Save arkilis/a52403cbb327b1b2a5890683ec591e8a to your computer and use it in GitHub Desktop.
UIColor+HexColor.m
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 = [NSScanner scannerWithString:hexString]; | |
[scanner setScanLocation:1]; // bypass '#' character | |
[scanner scanHexInt:&rgbValue]; | |
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((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