关于tableViewCell 中大量圆形头像 优化性能的笔记

来源:互联网 发布:java的集成开发环境 编辑:程序博客网 时间:2024/06/05 20:03

由于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;}
0 0