你是用什么方法設(shè)置圖片圓角?
首先你是否是這么設(shè)置的:
//cornerRadius 設(shè)置為self.iconImage圖片寬度的一半(圓形圖片)
self.iconImage.layer.cornerRadius = 20;
self.iconImage.layer.masksToBounds = YES;
在此之后建議大家盡量不要這么設(shè)置, 因?yàn)槭褂脠D層過量會有卡頓現(xiàn)象, 特別是弄圓角或者陰影會很卡, 如果設(shè)置圖片圓角我們一般用繪圖來做:
/** 設(shè)置圓形圖片(放到分類中使用) */
- (UIImage *)cutCircleImage {
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0);
// 獲取上下文
CGContextRef ctr = UIGraphicsGetCurrentContext();
// 設(shè)置圓形
CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
CGContextAddEllipseInRect(ctr, rect);
// 裁剪
CGContextClip(ctr);
// 將圖片畫上去
[self drawInRect:rect];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
這個方法就是設(shè)置圓角圖片, 效率很高, 不會造成卡頓現(xiàn)象, 大家要把這個方法單獨(dú)放到分類中使用