正文
###方法一
imageView.layer.cornerRadius = width/2; //imageView是正方形,此时角度设为width或height的一半
imageView.layer.masksToBouds = YES;
PS:这种方法比较常用,但是在iOS9.0以下存在一个问题,比如一个tableView上存在过多使用这样设置圆角的图片,会造成FPS下降,iOS9.0官方修复了这个问题
###方法二
//1、开启图形上下文;比例因素:当前点与像素比例
UIGraphicsBeginImageContextWithOptions(image.size,NO,0);
//2、描述裁剪区域
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0,0,image.size.width,image.size.height)];
//3、设置裁剪区域
[path addClip];
//4、画图片
[image drawAtPotnt:CGPointZero];
//5、取出图片
image = UIGraphicsGetImageFromCurrentImageContext();
//6、关闭上下文
UIGraphiceEndImageContext();
//7、给imageView赋值
imageView.image = image;