设置图片圆角
2015-07-02 16:46
232 查看
//----------第一种方法-------------------
// _img.layer.cornerRadius = 150;
// _img.layer.masksToBounds = YES;
// _img.layer.contents = [UIImage imageNamed:@"zsy.jpg"];
//// _img.image = [UIImage imageNamed:@"zsy.jpg"];
// [_img.layer needsDisplay];
//
//----------第二种方法(优化了性能)-------------------
// _img.layer.shouldRasterize = YES;
// _img.layer.rasterizationScale = self.view.window.screen.scale;
// _img.layer.cornerRadius = 150;
// _img.layer.masksToBounds = YES;
// _img.image = [UIImage imageNamed:@"zsy.jpg"];
//
//----------第三种方法(优化了性能)-------------------
//获取图片
UIImage *imge = [UIImage imageNamed:@"zsy.jpg"];
//Creates a bitmap-based graphics context
UIGraphicsBeginImageContextWithOptions(_img.bounds.size, NO, 1.0);
//Creates and returns a new UIBezierPath objec
[[UIBezierPath bezierPathWithRoundedRect:_img.bounds cornerRadius:150]addClip];
// [self.view.layer drawInContext:<#(CGContextRef)#>];
[imge drawInRect:_img.bounds];
_img.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// _img.layer.cornerRadius = 150;
// _img.layer.masksToBounds = YES;
// _img.layer.contents = [UIImage imageNamed:@"zsy.jpg"];
//// _img.image = [UIImage imageNamed:@"zsy.jpg"];
// [_img.layer needsDisplay];
//
//----------第二种方法(优化了性能)-------------------
// _img.layer.shouldRasterize = YES;
// _img.layer.rasterizationScale = self.view.window.screen.scale;
// _img.layer.cornerRadius = 150;
// _img.layer.masksToBounds = YES;
// _img.image = [UIImage imageNamed:@"zsy.jpg"];
//
//----------第三种方法(优化了性能)-------------------
//获取图片
UIImage *imge = [UIImage imageNamed:@"zsy.jpg"];
//Creates a bitmap-based graphics context
UIGraphicsBeginImageContextWithOptions(_img.bounds.size, NO, 1.0);
//Creates and returns a new UIBezierPath objec
[[UIBezierPath bezierPathWithRoundedRect:_img.bounds cornerRadius:150]addClip];
// [self.view.layer drawInContext:<#(CGContextRef)#>];
[imge drawInRect:_img.bounds];
_img.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
相关文章推荐
- bootstrap之
- qt 安卓模拟器启动错误
- Android 图片轮番 继承ViewGroup实现 可以直接使用
- redis 集群
- JS验证身份证的合法性
- weblogic11_64下的java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.sql.Date
- 分表用到的一些函数/php mysql 前面补0
- DOM事件对象event、IE中的事件对象
- Java Serializable系列化与反系列化
- iOS程序员必须知道的Android要点
- Rigidbody.AddExplosionForce 添加爆炸力
- Linux下MySQL的操作
- android控件
- Android UI法宝的设计资源的开发
- @RequestBody与@ResponseBody处理输入参数和输出参数
- 用指向指针的指针的方法对字符串和整数排序
- TheValgrind Quick Start Guide
- Android瀑布流照片墙实现,体验不规则排列的美感
- 利用iframe进行ajax文件提交
- Activity的绘制流程简单分析(基于android 4.0源码进行分析)