您的位置:首页 > 编程语言

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

2016-01-19 09:37 344 查看
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 就是生成的图片
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: