
实现流程:在上下文绘制一个剪切后的圆;然后再将图片绘制上去;最后通过从上下文中取出这张图片
//加载剪切图片
UIImage *image = [UIImage imageNamed:@"阿狸头像"];
//1.获取上下文
UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
//2.绘制剪切路径----圆
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
[path addClip];
//3.绘制图片
[image drawAtPoint:CGPointZero];
//4.从上下文中取出剪切后的图片
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
//5.关闭上下文
UIGraphicsEndImageContext();
self.imageView.image = newImage;