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
layoutAttributesClasslayoutAttributesForElements(in:)layoutAttributesForItem(at:)layoutAttributesForInteractivelyMovingItem(at:withTargetPosition:)layoutAttributesForSupplementaryView(ofKind:at:)layoutAttributesForDecorationView(ofKind:at:)targetContentOffset(forProposedContentOffset:)targetContentOffset(forProposedContentOffset:withScrollingVelocity:)