颜色转image图片

2016-10-18  本文已影响13人  克拉克定律
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{    
    CGRect rect = CGRectMake(0, 0, size.width, size.height);    
    UIGraphicsBeginImageContext(rect.size);       
    CGContextRef context = UIGraphicsGetCurrentContext();       
    CGContextSetFillColorWithColor(context, [color   CGColor]);       
    CGContextFillRect(context, rect);       
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();       
    UIGraphicsEndImageContext();       
    return image;
}
上一篇 下一篇

猜你喜欢

热点阅读