Instance Method

prepare()

Tells the layout object to update the current layout.

Declaration

func prepare()

Discussion

Layout updates occur the first time the collection view presents its content and whenever the layout is invalidated explicitly or implicitly because of a change to the view. During each layout update, the collection view calls this method first to give your layout object a chance to prepare for the upcoming layout operation.

The default implementation of this method does nothing. Subclasses can override it and use it to set up data structures or perform any initial computations needed to perform the layout later.

See Also

Providing Layout Attributes

class var layoutAttributesClass: AnyClass

Returns the class to use when creating layout attributes objects.

func layoutAttributesForElements(in: CGRect)

Returns the layout attributes for all of the cells and views in the specified rectangle.

func layoutAttributesForItem(at: IndexPath)

Returns the layout attributes for the item at the specified index path.

func layoutAttributesForInteractivelyMovingItem(at: IndexPath, withTargetPosition: CGPoint)

Returns the layout attributes of an item when it is being moved interactively by the user.

func layoutAttributesForSupplementaryView(ofKind: String, at: IndexPath)

Returns the layout attributes for the specified supplementary view.

func layoutAttributesForDecorationView(ofKind: String, at: IndexPath)

Returns the layout attributes for the specified decoration view.

func targetContentOffset(forProposedContentOffset: CGPoint)

Returns the content offset to use after an animated layout update or change.