iOS——颜色转图片

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

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

    CGRect rect=CGRectMake(0.0f, 0.0f, 55.f, 1.f);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [color CGColor]);

    CGContextFillRect(context, rect);

    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return theImage;

}

转载于:https://my.oschina.net/u/3382458/blog/865758

你可能感兴趣的:(iOS——颜色转图片)