1 方法一:通過layer設(shè)置圓角
UIImageView *iconView = [[UIImageView alloc] init];
iconView.layer.cornerRadius = 25;
// 超出主層邊框就要裁剪掉
iconView.layer.masksToBounds = YES;
備注:iOS9以后使用cornerRadius,不會造成幀數(shù)殺手
2 方法二:在xib中設(shè)置

1D94EC12-4DFA-43BF-BCBB-F9ABCB43ED34.png
3 方法三:利用圖形上下文設(shè)置
// 顯示頭像,設(shè)置占位圖片
[_iconView sd_setImageWithURL:[NSURL URLWithString:item.image_list] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
// 加載成功就會調(diào)用
// 只要想生成新的圖片 => 圖形上下文
// 1.開啟圖形上下文
UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
// 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();
_iconView.image = image;
// 6.關(guān)閉上下文
UIGraphicsEndImageContext();
}];