Created
July 1, 2010 03:11
-
-
Save jdcrensh/459508 to your computer and use it in GitHub Desktop.
Extends UIColor for hex color values
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
@interface UIColor (Hex) | |
+ (UIColor *)colorWithHex:(uint)rgbValue; | |
@end | |
@implementation UIColor (Hex) | |
+ (UIColor *)colorWithHex:(uint)rgbValue { | |
float redValue = ((rgbValue & 0xFF0000) >> 16) / 255.0; | |
float greenValue = ((rgbValue & 0xFF00) >> 8) / 255.0; | |
float blueValue = (rgbValue & 0xFF) / 255.0; | |
return [UIColor colorWithRed:redValue green:greenValue blue:blueValue alpha:1.0]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment