您的位置:首页 > 产品设计 > UI/UE

iOS-UIImage 互转 UIColor

2015-11-23 17:12 429 查看
//UIColor 转UIImage
- (UIImage*) createImageWithColor: (UIColor*) color
{
CGRect rect=CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);

UIImage *senderImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return senderImage;
}

//UIImage转UIColor
[UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: