UITableView cornerRadius with border performance i

2019-02-22 12:03发布

I have some interesting notice with scrolling performance on UITableView with cornerRadius, borderWidth and borderColor enabled.

self.tableView.layer.cornerRadius = 10.f;
self.tableView.layer.borderWidth = 1.0f;
self.tableView.layer.borderColor = [UIColor whiteColor].CGColor;

If I remove borderWidth and borderColor than scrolling gets 60 FPS no problem. As long as I add those two properties to layer FPS drops.

Does anyone have a suggestion or explanation why this strange behavior happens?

Many Thanks!

2条回答
疯言疯语
2楼-- · 2019-02-22 12:16

CALayer having shouldRasterize property for this type of performance issue. Just set

self.tableView.layer.shouldRasterize = YES;

This single line saved my lot of time and work.

查看更多
祖国的老花朵
3楼-- · 2019-02-22 12:22

I just found out that cornerRadius with borderWidth sluggish tableView performance by a lot. So instead of 10.f radius I changed to 5.f and performance has increased amazingly. Still not perfect but noticeably better...

查看更多
登录 后发表回答