Instance Method

setCollectionViewLayout(_:animated:)

Changes the collection view’s layout and optionally animates the change.

Declaration

func setCollectionViewLayout(_ layout: UICollectionViewLayout, animated: Bool)

Parameters

layout

The new layout object for the collection view.

animated

Specify true if you want to animate changes from the current layout to the new layout specified by the layout parameter. Specify false to make the change without animations.

Discussion

This method makes the layout change without further interaction from the user. If you choose to animate the layout change, the animation timing and parameters are controlled by the collection view.

See Also

Changing the Layout

var collectionViewLayout: UICollectionViewLayout

The layout used to organize the collected view’s items.

func setCollectionViewLayout(UICollectionViewLayout, animated: Bool, completion: ((Bool) -> Void)?)

Changes the collection view’s layout and notifies you when the animations complete.

func finishInteractiveTransition()

Tells the collection view to finish an interactive transition by installing the intended target layout.

func cancelInteractiveTransition()

Tells the collection view to abort an interactive transition and return to its original layout object.

Customizing Collection View Layouts

Customize a view layout by changing the size of cells in the flow or implementing a mosaic style.