ios颜色生成图片的方法

来源:互联网 发布:淘宝客服工作好不好干 编辑:程序博客网 时间:2024/05/21 09:59

Mark一下

-(UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size

{

    CGRect rect =CGRectMake(0,0, size.width, size.height);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context =UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context,color.CGColor);

    CGContextFillRect(context, rect);

    UIImage *img =UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return img;

}

1 0
原创粉丝点击