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

你可能感兴趣的:(CGContext ----生成图片--image)