-
代码
// 获取出颜色中的具体色值
- (NSArray *)rgba_Nums:(UIColor *)color {
CGFloat red = 0.0;
CGFloat green = 0.0;
CGFloat blue = 0.0;
CGFloat alpha = 0.0;
[color getRed:&red green:&green blue:&blue alpha:&alpha];
return @[@(red), @(green), @(blue), @(alpha)];
}
NSArray *rgba_nums = [self rgba_Nums:HEX_RGBA(0xff1010, 0.9)];
GC_Log(@"全部 == %@", rgba_nums)
GC_Log(@"红 == %@", @([rgba_nums.firstObject floatValue] * 255));
GC_Log(@"绿 == %@", @([rgba_nums[1] floatValue] * 255));
GC_Log(@"蓝 == %@", @([rgba_nums[2] floatValue] * 255));
GC_Log(@"透明 == %@", @([rgba_nums.lastObject floatValue]));
- 效果