通过颜色生成图片,直接上代码

CGRect rect = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    UIColor *color = [UIColor colorWithRed:41/255.0 green:182/255.0 blue:246/255.0 alpha:1.0];

    CGContextSetFillColorWithColor(context, [color CGColor]);

    CGContextFillRect(context, rect);

    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

此时 img 就是生成的图片

posted @ 2016-01-19 09:37  大厨子的世界  阅读(287)  评论(0编辑  收藏  举报