invalidationContext(forPreferredLayoutAttributes:withOriginalAttributes:)
Retrieves a context object that identifies the portions of the layout that should change in response to dynamic cell changes.
Declaration
func invalidationContext(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes, withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutInvalidationContextParameters
- preferredAttributes:
The layout attributes returned by the cell’s Preferredlayoutattributesfitting(_:) method.
- originalAttributes:
The attributes that the layout object originally suggested for the cell.
Return Value
An invalidation context that includes information about what changes need to be made to the layout.
Discussion
The default implementation of this method creates an instance of the class provided by the invalidationContextClass class method and returns it. If you want to use a custom invalidation context object with your layout, always override that method and return your custom class.
Subclasses can override this method and use it to perform additional configuration of the invalidation context before returning it. In your custom implementation, call super so that the parent class can perform the basic configuration of the object.
See Also
Invalidating the layout
invalidateLayout()invalidateLayout(with:)invalidationContextClassshouldInvalidateLayout(forBoundsChange:)invalidationContext(forBoundsChange:)shouldInvalidateLayout(forPreferredLayoutAttributes:withOriginalAttributes:)invalidationContext(forInteractivelyMovingItems:withTargetPosition:previousIndexPaths:previousPosition:)invalidationContextForEndingInteractiveMovementOfItems(toFinalIndexPaths:previousIndexPaths:movementCancelled:)