博客> 方法 将color转成image
方法 将color转成image
2019-05-20 20:31 评论:0 阅读:823 财年小白
ios
  • (UIImage )imageWithColor:(UIColor )color { CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect);

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

    return image; }

收藏
0
sina weixin mail 回到顶部