UIColor和UIImage转换
2016-07-14 14:30
513 查看
UIColor 转UIImage
- (UIImage*) createImageWithColor: (UIColor*) color
{
CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
UIImage转UIColor
[UIColor colorWithPatternImage:[UIImageimageNamed:@"EmailBackground.png"]]
- (UIImage*) createImageWithColor: (UIColor*) color
{
CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
UIImage转UIColor
[UIColor colorWithPatternImage:[UIImageimageNamed:@"EmailBackground.png"]]
相关文章推荐
- UIslider 详解
- Web自动化框架LazyUI使用手册(5)--模板工程:LazyUI-template详解
- Web自动化框架LazyUI使用手册(5)--模板工程:LazyUI-template详解
- Runtime Permissions处理、servie+AsyncQueryHandler+AsyncTask结合用法
- easyUI combobox在火狐浏览器不兼容问题
- 如何在DuiLib中绘制用户数据
- uva 1252 Twenty Questions
- Vue.js入门学习(1)
- iOS 把你的UILabel多彩起来
- guess-number-higher-or-lower
- 简单使用Reveal:分析IOS UI界面
- UIView.clipsToBounds 让子 View 只显示落在父 View 的 Frame 部分
- 基于 CoreText 实现的高性能 UITableView
- 1051. Pop Sequence (25)
- KendoUI模板引擎 - #号语法
- STL之unique()去重函数
- request方法大全
- UILocalNotification在 iOS8中无效问题
- UESTC149 解救小Q(bfs)
- UIButton实现背景拉伸