标签:
/**
* 获取UIColor对象的HSB字符串值。
*
*/
- (NSString *)getHSBStringByColor:(UIColor *)originColor {
// Method provided by the Colours class extension
NSDictionary *hsbDict = [self getHSBAValueByColor:originColor];
return [NSString stringWithFormat:@"(%0.2f, %0.2f, %0.2f)",
[hsbDict[@"H"] floatValue],
[hsbDict[@"S"] floatValue],
[hsbDict[@"B"] floatValue]];
}
/**
* 获取UIColor对象的HSBA值。
*
*/
- (NSDictionary *)getHSBAValueByColor:(UIColor *)originColor
{
CGFloat h=0,s=0,b=0,a=0;
if ([originColor respondsToSelector:@selector(getHue:saturation:brightness:alpha:)]) {
[originColor getHue:&h saturation:&s brightness:&b alpha:&a];
}
return @{@"H":@(h),
@"S":@(s),
@"B":@(b),
@"A":@(a)};
}
标签:
原文地址:http://blog.csdn.net/shouqiangwei/article/details/42455201