由于tableView 中引用了大量的圆形头像设计,导致性能问题,最后找到一种最好的方案,做下笔记,仅供自己参考,如有错误,请指正。
最好的方案:
=====》一层imageView显示正常图片,上边覆盖一层imageView 显示中间位透明圆形的图片。
其他设置圆角的方案:
方案一;贝塞尔曲线
uiview+addition;
- (void)setAllCornerWithRoundedCornersSize:(CGFloat)cornersSize {
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
cornerRadius:cornersSize];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
self.layer.mask = maskLayer;
}
方案二;
-(void) addBorderWithColor:(UIColor *) color width:(float) width radius:(float) radius{
self.layer.borderColor = color.CGColor;
self.layer.borderWidth = width;
self.layer.cornerRadius = radius;
self.layer.masksToBounds = YES;
}