I have been struggling with this issue for weeks now. Anyway, CALayer's are awful. They cause so much lag and make my UI look even worse.
Pretty much I have a simple UITableView that I have maxed out in efficiency and all of the lag when scrolling comes from 3 lines of code:
CALayer *imageLayer2 = [cell.imageView layer];
[imageLayer2 setMasksToBounds:YES];
[imageLayer2 setCornerRadius:10.0];
I have tried to set the setMaskToBounds to NO, but then no rounded corners are applied to my UIImageView. It seems that this issue is worse on iPads then on iPhones for some odd reason but ill just stick to finding a workaround for now. Also this code is in my cellForRowAtIndexPath but only is executed if a new cell is needed so it is not always called.
Anyway, what do you recommend I do instead of using CALayers to get rid of this lag?
Thanks!
I think the problem here is because you are doing this every time the cellForRowAtIndex
is called. What I would advise, is store the image already with the mask and the corner radius, when you actually need then again, you ask the model to retrieve the image and not calculate it again. The cellForRowAtIndex
, is a sensible spot, and you should avoid doing expensive operations in it.