Instance Method

invalidationContext(forPreferredLayoutAttributes:withOriginalAttributes:)

Returns 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) -> UICollectionViewLayoutInvalidationContext

Parameters

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

func invalidateLayout()

Invalidates the current layout and triggers a layout update.

func invalidateLayout(with: UICollectionViewLayoutInvalidationContext)

Invalidates the current layout using the information in the provided context object.

class var invalidationContextClass: AnyClass

Returns the class to use when creating an invalidation context for the layout.

func shouldInvalidateLayout(forBoundsChange: CGRect) -> Bool

Asks the layout object if the new bounds require a layout update.

func invalidationContext(forBoundsChange: CGRect) -> UICollectionViewLayoutInvalidationContext

Returns a context object that defines the portions of the layout that should change when a bounds change occurs.