一,[_iconView sd_setImageWithURL:[NSURL URLWithString:item.image_list] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"] options:SDWebImageCacheMemoryOnly completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
// 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 drawAtPoint:CGPointZero];
// 5.取出圖片
image = UIGraphicsGetImageFromCurrentImageContext();
// 6.關閉上下文
UIGraphicsEndImageContext();
_iconView.image = image;
}];
二,// 從xib加載就會調用一次
- (void)awakeFromNib {
// Initialization code
// 設置頭像圓角,iOS9蘋果修復
//? ? _iconView.layer.cornerRadius = 30;
//? ? _iconView.layer.masksToBounds = YES;
}