Class

UICollectionReusableView

The UICollectionReusableView class defines the behavior for all cells and supplementary views presented by a collection view. Reusable views are so named because the collection view places them on a reuse queue rather than deleting them when they are scrolled out of the visible bounds. Such a view can then be retrieved and repurposed for a different set of content.

Overview

Subclassing Notes

This class is intended to be subclassed. Most methods defined by this class have minimal or no implementations. You are not required to override any of the methods but can do so in cases where you want to respond to changes in the view’s usage or layout.

Symbols

Reusing Cells

var reuseIdentifier: String?

A string that identifies the purpose of the view.

func prepareForReuse()

Performs any clean up necessary to prepare the view for use again.

Managing Layout Changes

func preferredLayoutAttributesFitting(UICollectionViewLayoutAttributes)

Gives the cell a chance to modify the attributes provided by the layout object.

func apply(UICollectionViewLayoutAttributes)

Applies the specified layout attributes to the view.

func willTransition(from: UICollectionViewLayout, to: UICollectionViewLayout)

Tells your view that the layout object of the collection view is about to change.

func didTransition(from: UICollectionViewLayout, to: UICollectionViewLayout)

Tells your view that the layout object of the collection view changed.