1.通過(guò)對(duì)設(shè)置imageView中l(wèi)ayer的圓角半徑實(shí)現(xiàn)圓形圖片
// 設(shè)置圓角半徑
imageView.layer.cornerRadius = imageView.width * 0.5;
// 超出主層的部分裁減掉
imageView.layer.masksToBounds = YES;
2.通過(guò)上下文對(duì)圖片進(jìn)行裁剪實(shí)現(xiàn)圓形圖片
// 1.開(kāi)啟圖形上下文
UIGraphicsBeginImageContext(image.size);
// 2.描述圓形裁剪區(qū)域
UIBezierPath *clipPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
// 3.設(shè)置裁剪區(qū)域
[clipPath addClip];
// 4.繪圖
[image drawAtPoint:CGPointZero];
// 5.取出圖片
image = UIGraphicsGetImageFromCurrentImageContext();
// 6.關(guān)閉上下文
UIGraphicsEndImageContext();
imageView.image = image;