美文网首页iOS Developer
UIColor转成图片

UIColor转成图片

作者: idream | 来源:发表于2017-05-03 17:12 被阅读33次

    #pragma mark 图片处理

    + (UIImage *)imageFromColor:(UIColor *)color Width:(int)width Height:(int) height{

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

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [color CGColor]);

    CGContextFillRect(context, rect);

    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return img;

    }

    相关文章

      网友评论

        本文标题:UIColor转成图片

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