4

I'm trying to optimize the scrolling speed and smoothness of my UICollectionView (using a custom layout) that has about 400 cells, 150 of which are visible on the screen at the same time.

The cells themselves aren't very complex: They consist of a (fully opaque) colored background and two labels (with the same background color).

So far, I've read dozens of posts on optimizing speed by

  • properly reusing cells,
  • avoiding transparency in all backgrounds,
  • avoiding box shadows,
  • avoiding corner radius, and
  • avoiding fractional cell positions and sizes.

Despite all these optimizations, I still can't scroll smoothly with 60 fps. I've also tried layer rasterization (shouldRasterize) after dequeuing cells, but that had a negative impact on performance.

Reducing the amount of cells that are visible at the same time is the only thing that improved performance — scrolling is totally smooth with fewer cells. Unfortunately, that's not an option.

What else can I do to get close to 60 fps with many UICollectionViewCells visible at once?

Marius Schulz
  • 15,976
  • 12
  • 63
  • 97

3 Answers3

3

If you have shadows on cell, check if using shouldRasterize on the cells layer could improve the framerate.
Also, never do blocking actions inside the - collectionView:cellForItemAtIndexPath: method

Power78
  • 311
  • 4
  • 12
1

The UICollectionView behaves much like the UITableView

Use this link for a reference : UITableView Optimization

Community
  • 1
  • 1
Vinay Jain
  • 1,653
  • 20
  • 28
0

If it helps anyone, I had a similar problem, it was down to cornerRadius on the cell and the UIView within the cell. I was able to remove it from the cell and still keep the asthetic I was looking for with the cornerRadius on the UIView. End result smooth scrolling.

Sutto
  • 1
  • 1