gpt4 book ai didi

iphone - 使用 Quartz 层是否会降低 UITableView 滚动性能?

转载 作者:行者123 更新时间:2023-12-03 20:58:16 26 4
gpt4 key购买 nike

我有一个 UIImageView,它在我的自定义绘制的 UITableViewCell 上进行舍入:

        rect = CGRectMake(13, 10, 48, 48);
avatar = [[UIImageView alloc] initWithFrame:rect];
[self.contentView addSubview: avatar];

CALayer * l = [avatar layer];
[l setMasksToBounds:YES];
[l setCornerRadius:9.0];

我注意到我的 UITableView 滚动性能有所下降。不确定是否与圆角有关?

最佳答案

圆角会降低绘图速度。蒙版层速度稍快一些。将角“烘焙”到内容中(作为图像或在 drawRect: 中使用剪切路径)速度更快。

分配新的 View /图层也会减慢滚动速度——尽可能重用它们(创建一个 UITableViewCell 子类,在 init 中创建 subview 并在dealloc 通常效果很好)

话虽如此,添加额外的 View 不会明显降低性能。

关于iphone - 使用 Quartz 层是否会降低 UITableView 滚动性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3323414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com