Protocol

NSCollectionViewDelegateFlowLayout

A set of methods that a delegate implements to provide layout information to a flow layout object in a collection view.

Declaration

@protocol NSCollectionViewDelegateFlowLayout

Overview

Implement the methods of this protocol when you want to customize the layout behavior and perhaps return different values for different items or sections.

All of the methods in this protocol are optional, so you can implement only the methods you need to achieve the desired layout. If you do not implement a particular method, the flow layout object obtains default values from its own properties and applies them uniformly. Implement your methods in the object you assign to the delegate property of the collection view itself.

Topics

Getting the Size of Items

- collectionView:layout:sizeForItemAtIndexPath:

Asks the delegate for the size of the specified item.

Getting the Section Spacing

- collectionView:layout:insetForSectionAtIndex:

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

- collectionView:layout:minimumLineSpacingForSectionAtIndex:

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

- collectionView:layout:minimumInteritemSpacingForSectionAtIndex:

Asks the delegate for the spacing between successive items of a single row or column.

Getting the Header and Footer Sizes

- collectionView:layout:referenceSizeForHeaderInSection:

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

- collectionView:layout:referenceSizeForFooterInSection:

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

Relationships

See Also

Layouts

Using Collection View Compositional Layouts and Diffable Data Sources

Learn how to bring complex, high-performance layouts to your app, and simplify updating and managing your UI.

NSCollectionViewFlowLayout

A layout that organizes items into a flexible and configurable arrangement.

NSCollectionViewGridLayout

A layout that displays a single section of items in a row and column grid.

NSCollectionViewTransitionLayout

An object that implements custom behaviors when changing from one layout to another in a collection view.

NSCollectionViewLayoutAttributes

An object that contains layout-related attributes for an element in a collection view.

NSCollectionViewLayout

An abstract base class that you subclass and use to generate layout information for a collection view.