Instance Method

shouldInvalidateLayout(forBoundsChange:)

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

Declaration

func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool

Parameters

newBounds

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.

Discussion

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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software