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 *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
UIImage转UIColor
[UIColor colorWithPatternImage:[UIImageimageNamed:@“bg.png"]]
本文介绍了如何在iOS开发中将UIColor转换为UIImage,以及如何从UIImage获取UIColor的方法,提供了实用的代码示例。
851

被折叠的 条评论
为什么被折叠?



