1.使用layer去裁剪 这两行代码在iOS9之前滚动tableview的时候会出现卡顿的显现,iOS9已经修复了卡顿现象,建议使用第二种方法
UIImage *image = [UIImage imageNamed:@"avar"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.layer.cornerRadius = image.size.width/2;
imageView.layer.masksToBounds = YES;```
2.使用上下文裁剪图片
<pre> UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
//描述裁剪区域
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
//设置裁剪区域
[path addClip];
//画图片
[image drawAtPoint:CGPointZero];
//取出图片
image = UIGraphicsGetImageFromCurrentImageContext();
//关闭上下文
UIGraphicsEndImageContext();
imageView.image = image;</pre>