<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UICollectionViewLayout/invalidationContext(forBoundsChange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UICollectionViewLayout(im)invalidationContextForBoundsChange:"
  },
  "title" : "invalidationContext(forBoundsChange:)"
}
-->

# invalidationContext(forBoundsChange:)

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

```
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`](/documentation/UIKit/UICollectionViewLayout/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)