通过颜色生成图片,直接上代码
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 就是生成的图片
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 就是生成的图片
相关文章推荐
- java学习—day_6
- 集算器协助java处理多样性数据源之HDFS
- 笛卡尔积算法的Java实现
- php性能优化
- eclipse启动报错"failed to create the java virtual machine"
- 随机生成字符串-php-js
- [Windows Server 2012] 更换PHP版本方法
- leetcode power of three
- C++下caffe使用教程
- QT事件过滤器、事件重载和焦点事件
- 常用加密算法的Java实现总结
- Java 构造方法,初始化块,静态初始化块
- C语言实现字节流与十六进制字符串的相互转换
- lua中获取时间
- 【代码笔记】点击一个button,出6个button
- 【代码笔记】点击一个button,出6个button
- myeclipse 2013 SR2 安装svn
- Java 集合:Collection 系列(HashSet)
- 使用Maven运行Java main的3种方式
- 如何将eclipse项目导入android studio中