Protocol

UICollectionViewDelegateFlowLayout

The UICollectionViewDelegateFlowLayout protocol defines methods that let you coordinate with a UICollectionViewFlowLayout object to implement a grid-based layout. The methods of this protocol define the size of items and the spacing between items in the grid.

Overview

All of the methods in this protocol are optional. If you do not implement a particular method, the flow layout delegate uses values in its own properties for the appropriate spacing information.

The flow layout object expects the collection view’s delegate object to adopt this protocol. Therefore, implement this protocol on object assigned to your collection view’s delegate property.

Symbols

Getting the Size of Items

Getting the Section Spacing

func collectionView(UICollectionView, layout: UICollectionViewLayout, insetForSectionAt: Int)

Asks the delegate for the margins to apply to content in the specified section.

func collectionView(UICollectionView, layout: UICollectionViewLayout, minimumLineSpacingForSectionAt: Int)

Asks the delegate for the spacing between successive rows or columns of a section.

func collectionView(UICollectionView, layout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt: Int)

Asks the delegate for the spacing between successive items in the rows or columns of a section.

Getting the Header and Footer Sizes

func collectionView(UICollectionView, layout: UICollectionViewLayout, referenceSizeForHeaderInSection: Int)

Asks the delegate for the size of the header view in the specified section.

func collectionView(UICollectionView, layout: UICollectionViewLayout, referenceSizeForFooterInSection: Int)

Asks the delegate for the size of the footer view in the specified section.

Relationships