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

# shouldInvalidateLayout(forPreferredLayoutAttributes:withOriginalAttributes:)

Asks the layout object if changes to a self-sizing cell require a layout update.

```
func shouldInvalidateLayout(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes, withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> Bool
```

## Parameters

`preferredAttributes`

The layout attributes returned by the cell’s [`preferredLayoutAttributesFitting(_:)`](/documentation/UIKit/UICollectionReusableView/preferredLayoutAttributesFitting(_:)) method.

`originalAttributes`

The attributes that the layout object originally suggested for the cell.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the layout should be invalidated or <doc://com.apple.documentation/documentation/Swift/false> if it should not.

## Discussion

When a collection view includes self-sizing cells, the cells are given the opportunity to modify their own layout attributes before those attributes are applied. A self-sizing cell might do this to specify a different cell size than the one the layout object provides. When the cell provides a different set of attributes, the collection view calls this method to determine if the cell’s change requires a larger layout refresh.

If you are implementing a custom layout, you can override this method and use it to determine if your layout should be invalidated based on the specified attributes. The default implementation of this method returns <doc://com.apple.documentation/documentation/Swift/false>.

---

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)