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;

}

posted @ 2017-04-07 13:57  Da雪山  阅读(557)  评论(0编辑  收藏  举报