Created
March 15, 2014 08:40
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
@interface UIColor (HSBFunctions) | |
- (UIColor *)lightenedColorByPercent:(CGFloat)percent; | |
- (UIColor *)darkenedColorByPercent:(CGFloat)percent; | |
@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+HSBFunctions.h" | |
@implementation UIColor (HSBFunctions) | |
- (UIColor *)lightenedColorByPercent:(CGFloat)percent | |
{ | |
CGFloat hue, saturation, brightness, alpha; | |
[self getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha]; | |
return [UIColor colorWithHue:hue saturation:saturation brightness:(brightness + 1.0 * (percent / 100.0)) alpha:alpha]; | |
} | |
- (UIColor *)darkenedColorByPercent:(CGFloat)percent | |
{ | |
CGFloat hue, saturation, brightness, alpha; | |
[self getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha]; | |
return [UIColor colorWithHue:hue saturation:saturation brightness:(brightness - 1.0 * (percent / 100.0)) alpha:alpha]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment