//将UIColor转换为RGB值
- (NSMutableArray *) changeUIColorToRGB:(UIColor *)color
{
NSMutableArray *RGBStrValueArr = [[NSMutableArray alloc] init];
NSString *RGBStr = nil;
//获得RGB值描述
NSString *RGBValue = [NSString stringWithFormat:@"%@",color];
//将RGB值描述分隔成字符串
NSArray *RGBArr = [RGBValue componentsSeparatedByString:@" "];
//获取红色值
int r = [[RGBArr objectAtIndex:1] intValue] * 255;
RGBStr = [NSString stringWithFormat:@"%d",r];
[RGBStrValueArr addObject:RGBStr];
//获取绿色值
int g = [[RGBArr objectAtIndex:2] intValue] * 255;
RGBStr = [NSString stringWithFormat:@"%d",g];
[RGBStrValueArr addObject:RGBStr];
//获取蓝色值
int b = [[RGBArr objectAtIndex:3] intValue] * 255;
RGBStr = [NSString stringWithFormat:@"%d",b];
[RGBStrValueArr addObject:RGBStr];
//返回保存RGB值的数组
return [RGBStrValueArr autorelease];
}
将UIColor转换为RGB值
最新推荐文章于 2022-06-09 17:35:56 发布