[iOS] 绘制纯色图片

+ (UIImage *)createImageWithColor:(UIColor *)color frame:(CGRect)rect

{

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [color CGColor]);

    CGContextFillRect(context, rect);

    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();    

    return theImage;

}

你可能感兴趣的:([iOS] 绘制纯色图片)