Contents

invalidationContext(forBoundsChange:)

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

Declaration

func invalidationContext(forBoundsChange newBounds: CGRect) -> UICollectionViewLayoutInvalidationContext

Parameters

  • newBounds:

    The new bounds for the collection view.

Return Value

An invalidation context that describes the changes that need to be made. Do not return nil.

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.

You can override this method if you want to create and configure your custom invalidation context in response to a bounds change. If you override this method, you must call super first to get the invalidation context object to return. After getting this object, set any custom properties and return it.

See Also

Invalidating the layout