通过UIColor创建图片
2016-04-13 20:14
399 查看
不多说,代码如下:
- (UIImage *)createImageWithColor:(UIColor *)color
{
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef contTextRef = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(contTextRef, [color CGColor]);
CGContextFillRect(contTextRef, rect);
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndPDFContext();
return image;
}
- (UIImage *)createImageWithColor:(UIColor *)color
{
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef contTextRef = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(contTextRef, [color CGColor]);
CGContextFillRect(contTextRef, rect);
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndPDFContext();
return image;
}
相关文章推荐
- Android UI-实现底部切换标签(fragment)
- lightoj 1369 - Answering Queries 数学
- WH服务器框架分析系列一:内核模块的基石CQueueService
- UIImagePickerController以中文显示界面
- iOS UITableView 引起的崩溃问题
- IOS开发之所有类型的UIKeyboardType图片展示
- nrf51822, How to use a vendor specific UUID?
- UIUItextfield输入类似银行卡号需要每四位加一个空格的实现
- 1-3 Bags,Queues and Stacks
- kendo ui treeview设置节点选中
- AVOSCloud(AVOSCloud.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode se
- iOS-UIView坐标系转换-convertRect toview
- does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), o
- UITextView 控制输入字数总结
- 错误: Unknown class XXX in Interface Builder file
- xml:Invalid byte 2 of 2-byte UTF-8 sequence
- android5.1添加Email分享,bluetooth分享
- 自定义UIActivityIndicatorView大小
- IOS-UI学习笔记(九宫格应用管理)
- 从客户端中检测到有潜在危险的 Request.Form 值