UIColor 直接生成 UIImage 和 圆角纯色UIImage
来源:互联网 发布:刷积分软件 编辑:程序博客网 时间:2024/06/04 17:50
直接使用UIColor生成所需要才纯色UIImage
/** * 将UIColor变换为UIImage * **/+ (UIImage *)createImageWithColor:(UIColor *)color{ //设置长宽 CGRect rect = CGRectMake(0.0f, 0.0f, 5.0f, 5.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return resultImage;}
生成圆角纯色UIImage的方法
//生成圆角UIIamge 的方法- (UIImage *)imageWithRoundedCornersSize:(float)cornerRadius{ UIImage *original = self; CGRect frame = CGRectMake(0, 0, original.size.width, original.size.height); // 开始一个Image的上下文 UIGraphicsBeginImageContextWithOptions(original.size, NO, 1.0); // 添加圆角 [[UIBezierPath bezierPathWithRoundedRect:frame cornerRadius:cornerRadius] addClip]; // 绘制图片 [original drawInRect:frame]; // 接受绘制成功的图片 UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image;}
0 0
- UIColor 直接生成 UIImage 和 圆角纯色UIImage
- 代码生成纯色uiimage
- UIColor生成UIImage
- 由UIColor 生成 UIImage
- UIColor和UIImage转换
- UIColor和UIImage转换
- UIImage 和 UIColor 互转
- UIColor和UIImage转换
- UIColor和UIImage互转
- UIColor和UIImage转换
- 把UIColor(纯色值)对象转化成UIImage对象
- UIImage和UIColor的转换
- uiimage和uicolor的转换
- 代码创建纯色UIImage
- IOS 由RGB、UIColor生成UIImage
- UIImage和UIColor之间的转变
- IOS中uiimage和uicolor相互转化
- iOS中uiimage和uicolor相互转化
- 合并两个排序的链表(剑指offer)
- matlab高手博客记录
- 1.3 对话框透明度
- 1218 -- 高精度加法
- Java____SpringMVC教学资源(坑)
- UIColor 直接生成 UIImage 和 圆角纯色UIImage
- 我来啦
- JNI完全手册
- python笔记0;extnd方法
- mysql 慢查询日志的使用
- *p++和*++p的区别
- mysql中insert和replace的区别
- Unity3D: NGUI自定义Atlas,Font
- win10 企业版,升级过后gemymotion无法启动