美文网首页
颜色转图片

颜色转图片

作者: junedeyu | 来源:发表于2019-04-28 11:31 被阅读0次

+ (UIImage *)cl_imageWithColor:(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/pncdnqtx.html