美文网首页
通过颜色生成图片

通过颜色生成图片

作者: 伯牙呀 | 来源:发表于2018-06-04 15:51 被阅读25次
+ (UIImage *)createImageWithColor:(UIColor *)color {
    
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    
    UIGraphicsBeginImageContext(rect.size);
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, color.CGColor);
    
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return image;
}

相关文章

网友评论

      本文标题:通过颜色生成图片

      本文链接:https://www.haomeiwen.com/subject/qdlysftx.html