- (NSDictionary *)getRGBDictionaryByColor:(UIColor *)originColor
{
CGFloat r=0,g=0,b=0,a=0;
if ([self
respondsToSelector:@selector(getRed:green:blue:alpha:)]) {
[originColor
getRed:&r green:&g
blue:&b alpha:&a];
}
else {
const CGFloat *components =
CGColorGetComponents(originColor.CGColor);
r = components[0];
g = components[1];
b = components[2];
a = components[3];
}
return @{@"R":@(r),
@"G":@(g),
@"B":@(b),
@"A":@(a)};
}
时间: 2024-10-10 07:21:30