---
title: "traitCollectionDidChange(_:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitraitenvironment/traitcollectiondidchange(_:)"
---

# traitCollectionDidChange(_:)

Reports changes in the iOS interface environment.

## Declaration

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

## Parameters

- `previousTraitCollection`: The doc://com.apple.uikit/documentation/UIKit/UITraitCollection object before the interface environment changed.

## Mentioned in

Adapting your app when traits change Checking the availability of 3D Touch Responding to changing display modes on Apple TV Scaling fonts automatically

## Discussion

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: - (void) traitCollectionDidChange: (UITraitCollection *) previousTraitCollection {     [super traitCollectionDidChange: previousTraitCollection];     if ((self.traitCollection.verticalSizeClass != previousTraitCollection.verticalSizeClass)         || (self.traitCollection.horizontalSizeClass != previousTraitCollection.horizontalSizeClass)) {         // Your custom implementation here.     } }
