一,[_iconView sd_setImageWithURL:[NSURL URLWithString:item.image_list] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"] options:SDWebImageCacheMemoryOnly completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
// 1.開啟圖形上下文
// 比例因素:當(dāng)前點(diǎn)與像素比例
UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
// 2.描述裁剪區(qū)域
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
// 3.設(shè)置裁剪區(qū)域;
[path addClip];
// 4.畫圖片
[image drawAtPoint:CGPointZero];
// 5.取出圖片
image = UIGraphicsGetImageFromCurrentImageContext();
// 6.關(guān)閉上下文
UIGraphicsEndImageContext();
_iconView.image = image;
}];
二,// 從xib加載就會(huì)調(diào)用一次
- (void)awakeFromNib {
// Initialization code
// 設(shè)置頭像圓角,iOS9蘋果修復(fù)
//? ? _iconView.layer.cornerRadius = 30;
//? ? _iconView.layer.masksToBounds = YES;
}