首页 > 其他 > 详细

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

时间:2016-01-19 10:25:08      阅读:249      评论:0      收藏:0      [点我收藏+]

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 就是生成的图片

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

原文:http://www.cnblogs.com/dewengood/p/5141186.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!