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

# traitCollectionDidChange(_:)

Reports changes in the iOS interface environment.

```
func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?)
```

## Parameters

`previousTraitCollection`

The [`UITraitCollection`](/documentation/UIKit/UITraitCollection) object before the interface environment changed.

## Discussion

The system calls this method when the iOS interface environment changes. Implement this method in view controllers and views, according to your app’s needs, to respond to such changes. For example, you might adjust the layout of the subviews of a view controller when someone rotates from portrait to landscape orientation. The default implementation of this method is empty.

At the beginning of your implementation, call `super` to ensure that interface elements higher in the view hierarchy have an opportunity to adjust their layout first. Use code similar to this:

```objc
- (void) traitCollectionDidChange: (UITraitCollection *) previousTraitCollection {
    [super traitCollectionDidChange: previousTraitCollection];
    if ((self.traitCollection.verticalSizeClass != previousTraitCollection.verticalSizeClass)
        || (self.traitCollection.horizontalSizeClass != previousTraitCollection.horizontalSizeClass)) {
        // Your custom implementation here.
    }
}
```

---

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)