美文网首页
iOS 颜色转为image

iOS 颜色转为image

作者: 夜半度微凉 | 来源:发表于2020-05-30 17:09 被阅读0次

+ (UIImage*)createImageWithColor:(UIColor*)color {

    CGRectrect=CGRectMake(0,0,1,1);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [color CGColor]);

    CGContextFillRect(context, rect);

    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return theImage;

}

相关文章

网友评论

      本文标题:iOS 颜色转为image

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