圓角處理

一,[_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;

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容