Created
September 26, 2011 22:54
-
-
Save madninja/1243675 to your computer and use it in GitHub Desktop.
UIColor RGBExtensions
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
#import <UIKit/UIColor.h> | |
@interface UIColor (RgbExtensions) | |
+(UIColor *)rgbColorWithRed:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b; | |
+(UIColor *)rgbaColorWithRed: (CGFloat)r green:(CGFloat)g blue:(CGFloat)b alpha:(CGFloat)a; | |
@end |
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
#import "UIColor+RgbExtensions.h" | |
@implementation UIColor (RgbExtensions) | |
+(UIColor *)rgbaColorWithRed:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b alpha:(CGFloat)a { | |
return [UIColor colorWithRed: r/255.0 green: g/255.0 blue: b/255.0 alpha: a/255.0]; | |
} | |
+(UIColor *)rgbColorWithRed:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b { | |
return [UIColor colorWithRed: r/255.0 green: g/255.0 blue: b/255.0 alpha: 255.0]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment