开发者

Does using Quartz layers slow down UITableView scrolling performance?

开发者 https://www.devze.com 2023-01-08 10:47 出处:网络
I have a UIImageView that is being rounded on my custom drawn UITableViewCell: 开发者_JS百科rect = CGRectMake(13, 10, 48, 48);

I have a UIImageView that is being rounded on my custom drawn UITableViewCell:

    开发者_JS百科    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];

I noticed my UITableView scrolling performance decreased a little bit. Not sure if it is related to the rounded corners though?


Rounded corners slow down drawing a lot. Mask layers are somewhat faster. "Baking" the corners into the content (as an image or using a clipping path in your drawRect:) is faster still.

Allocating new views/layers will also slow down your scrolling--reuse them wherever you can (creating a UITableViewCell subclass that creates the subviews in init and destroys them in dealloc generally works well)

That being said, adding additional views shouldn't reduce performance noticeably.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号