iOS中uiimage和uicolor相互转化
2015-09-01 09:11
357 查看
UIColor 转UIImage
- (UIImage*) createImageWithColor: (UIColor*) color
{
CGRect rect=CGRectMake(0,0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
UIImage转UIColor
[UIColor colorWithPatternImage:[UIImageimageNamed:@“bg.png"]]
- (UIImage*) createImageWithColor: (UIColor*) color
{
CGRect rect=CGRectMake(0,0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
UIImage转UIColor
[UIColor colorWithPatternImage:[UIImageimageNamed:@“bg.png"]]
相关文章推荐
- request.getRemoteUser() 方法
- priority_queue的用法
- 如何在高并发分布式系统中生成全局唯一Id
- UI:触摸事件 与 事件的回应
- UEFI Bootable USB Flash Drive - Create in Windows(WIN7 WIN8)
- Install and run DB Query Analyzer 6.04 on Microsoft Windows 10
- Install and run DB Query Analyzer 6.04 on Microsoft Windows 10
- APUE《UNIX 环境高级编程》读后感
- iOS_8_API:UITableViewRowAction
- NGUI实现翻牌效果
- 使用Qt Style Sheets制作UI特效
- 在UITableView中插入或者删除指定的行(或者节)
- SSRS 2012 Metro UI 高端报表视频教程【全国首家】
- MySQL树形查询结果封装成Json格式,返回给easyui treegrid
- WebMVC中EasyUI的ComboBox控件的运用
- EasyUI中Messager基本使用
- 设计模式之建造者模式---Builder
- gui学习
- UE4学习之关卡设计入门
- IOS基础UI之(三)手写UI和storyboard方式实现图片移动和缩放