iOS Developer

UIColor转成图片

2017-05-03  本文已影响33人  idream

#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;

}

上一篇下一篇

猜你喜欢

热点阅读