invalidateLayout(with:)
Invalidates specific parts of the layout using the specified context object.
Declaration
func invalidateLayout(with context: NSCollectionViewLayoutInvalidationContext)Parameters
- context:
The context object indicating which parts of the layout need to be updated.
Discussion
Call this method when you make changes that need to be reflected by the collection view, but which do not require the replacement of all of the layout information. You use this method to minimize the work performed by the layout object. Instead of optimizing everything, the specified context object indicates which parts of the layout need to be recomputed. All other layout information is left alone.
When implementing a custom layout, you can override this method and use it to process information provided by a custom invalidation context. You are not required to provide a custom invalidation context but might do so if you are able to provide additional properties that can help optimize layout updates. If you override this method, you must call super at some point in your implementation.