Instance Method


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


func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool



The new bounds of the collection view.

Return Value

true if the collection view requires a layout update or false if the layout does not need to change.


The default implementation of this method returns false. Subclasses can override it and return an appropriate value based on whether changes in the bounds of the collection view require changes to the layout of cells and supplementary views.

If the bounds of the collection view change and this method returns true, the collection view invalidates the layout by calling the invalidateLayout(with:) method.

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 invalidationContext(forBoundsChange: CGRect) -> UICollectionViewLayoutInvalidationContext

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