UIColor转成图片

#pragma mark 图片处理

+ (UIImage *)imageFromColor:(UIColor *)color Width:(int)width Height:(int) height{

CGRect rect = CGRectMake(0, 0,width,height);

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, [color CGColor]);

CGContextFillRect(context, rect);

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return img;

}

你可能感兴趣的:(UIColor转成图片)