开发者

Does using Quartz layers slow down UITableView scrolling performance?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜