CGContext ----生成图片--image

//获取图片

 

+ (UIImage*) getImageWithColor:(UIColor*)color andHeight:(CGFloat)height

{

  CGRect r= CGRectMake(0.0f, 0.0f, 1.0f, height);

  UIGraphicsBeginImageContext(r.size);

  CGContextRef context = UIGraphicsGetCurrentContext();

  

  CGContextSetFillColorWithColor(context, [color CGColor]);

  CGContextFillRect(context, r);

  

  UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

  UIGraphicsEndImageContext();

  return img;

}

原文地址:https://www.cnblogs.com/daxueshan/p/6677812.html