首先你是否是這么設(shè)置的:
// cornerRadius 設(shè)置為self.iconImage圖片寬度的一半(圓形圖片)
self.iconImage.layer.cornerRadius = 20;
self.iconImage.layer.masksToBounds = YES;
或者是在xib&storyboard中點(diǎn)擊要設(shè)置圓角的圖片:
這里寫(xiě)圖片描述
在此之后建議大家盡量不要這么設(shè)置, 因?yàn)槭褂脠D層過(guò)量會(huì)有卡頓現(xiàn)象, 特別是弄圓角或者陰影會(huì)很卡, 如果設(shè)置圖片圓角我們一般用繪圖來(lái)做:
/** 設(shè)置圓形圖片(放到分類(lèi)中使用) */
- (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);
// 將圖片畫(huà)上去
[self drawInRect:rect];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
這個(gè)方法就是設(shè)置圓角圖片, 效率很高, 不會(huì)造成卡頓現(xiàn)象, 大家要把這個(gè)方法單獨(dú)放到分類(lèi)中使用