ios – 使用cornerRadius的表格滚动缺乏性能,什么替代品?

我找不到我的问题的解决方案,所以希望一些专家可以帮助我.

我有很多单元格的tableview.对于每个单元格,我有一个圆角的图像视图:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UIImageView *exampleView;

...
exampleView.layer.cornerRadius =   5.f;
exampleView.clipsToBounds = YES;   
[cell.contentView addSubview:exampleView];
...

}

导致很大的缺乏滚动性能问题 – 当使用cornerRadius和clipsToBounds = YES时,任何替代解决方案?
(圆角图像视图包含图片,如果角落没有设置,滚动是平滑的,所以问题在这里)

编辑#1:澄清我已经阅读过其他职位:

...
exampleView.frame = CGRectMake(5.0f,size.height-15.0f,30.0f,30.0f);
exampleView.layer.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5].CGColor;
exampleView.layer.cornerRadius = 5.0f;
exampleView.layer.borderWidth       =   0.3f;
exampleView.layer.borderColor       =   [UIColor blackColor].CGColor;
exampleView.layer.masksToBounds = NO;
exampleView.layer.shouldRasterize = YES;
//exampleView.clipsToBounds = NO;
[exampleView setimage: myImage ];

编辑#2:
就像我的图像在圆角角落上看的一样.如何使图像适合圆角视图正确?还是我错过了什么?

解决方法

只需更改以下行
exampleView.layer.masksToBounds = YES;

在您的imageView中圆角.见下图.

桌面滚动是视图合成的一个问题.除了上述建议之外,这肯定有助于 –
设置UITableViewCell的contentView属性和backgroundView属性的opaque属性.走:

[cell.contentView setopaque:YES];
  [cell.backgroundView setopaque:YES];

这将有助于尽可能减少视图合成的工作.

还有一些额外的,先进的技术,需要您在滚动时使用异步处理来处理图像.如果上述技术工作,他们可能会过度使用.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...