美文网首页
ios根据颜色生成图片

ios根据颜色生成图片

作者: 508e0be44880 | 来源:发表于2016-12-03 15:25 被阅读160次

/**

*  生成图片

*

*  @param color  图片颜色

*  @param height 图片高度

*

*  @return 生成的图片

*/- (UIImage*) GetImageWithColor:(UIColor*)color andHeight:(CGFloat)height{CGRectr=CGRectMake(0.0f,0.0f,1.0f, height);UIGraphicsBeginImageContext(r.size);CGContextRefcontext =UIGraphicsGetCurrentContext();CGContextSetFillColorWithColor(context, [colorCGColor]);CGContextFillRect(context, r);UIImage*img =UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();returnimg;}

相关文章

网友评论

      本文标题:ios根据颜色生成图片

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