通过颜色创建image图片

来源:互联网 发布:qq软件下载最新版 编辑:程序博客网 时间:2024/05/16 13:00
- (UIImage *) createImageWithColor: (UIColor *) color 
{   
    CGRect rect = CGRectMake(0.0f,0.0f,1.0f,1.0f);  
    UIGraphicsBeginImageContext(rect.size);   
    CGContextRef context =UIGraphicsGetCurrentContext();  
    CGContextSetFillColorWithColor(context, [colorCGColor]);  
    CGContextFillRect(context, rect);   
    UIImage *myImage =UIGraphicsGetImageFromCurrentImageContext();  
    UIGraphicsEndImageContext();   
    return myImage;   
0 0