Customizing the Layout

The display of cells is not driven by the collection view itself but by the collection view’s layout. The layout object is responsible for the placement of cells onscreen. Layouts, in turn, are driven by a subclass of UICollectionViewLayout.

The flow layout that Photorama is currently using is UICollectionViewFlowLayout, which is the only concrete UICollectionViewLayout subclass provided by the UIKit framework.

Some of the properties you can customize on UICollectionViewFlowLayout are:

  • scrollDirection – Do you want to scroll vertically or horizontally?

  • minimumLineSpacing – What is the minimum spacing between lines?

  • minimumInteritemSpacing – What is the minimum spacing between items in a row ...

Get iOS Programming: The Big Nerd Ranch Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.