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

通过UIColor创建图片

2016-04-13 20:14 399 查看
不多说,代码如下:

- (UIImage *)createImageWithColor:(UIColor *)color

{

CGRect rect = CGRectMake(0, 0, 1, 1);

UIGraphicsBeginImageContext(rect.size);

CGContextRef contTextRef = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(contTextRef, [color CGColor]);

CGContextFillRect(contTextRef, rect);

UIImage * image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndPDFContext();

return image;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: