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

# setCollectionViewLayout(_:animated:)

Changes the collection view’s layout and optionally animates the change.

```
func setCollectionViewLayout(_ layout: UICollectionViewLayout, animated: Bool)
```

## Parameters

`layout`

The new layout object for the collection view.

`animated`

Specify <doc://com.apple.documentation/documentation/Swift/true> if you want to animate changes from the current layout to the new layout specified by the `layout` parameter. Specify <doc://com.apple.documentation/documentation/Swift/false> to make the change without animations.

## Discussion

This method makes the layout change without further interaction from the user. If you choose to animate the layout change, the animation timing and parameters are controlled by the collection view.

---

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)