<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "tvOS: 17.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITraitChangeObservable-67e94/TraitChangeHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:5UIKit23UITraitChangeObservableP05TraitC7Handlera"
  },
  "title" : "UITraitChangeObservable.TraitChangeHandler"
}
-->

# UITraitChangeObservable.TraitChangeHandler

A closure the system executes when observed traits change.

```
typealias TraitChangeHandler<TraitEnvironment> = (TraitEnvironment, UITraitCollection) -> Void where TraitEnvironment : UITraitEnvironment
```

## Parameters

`traitEnvironment`

The observed object containing the updated trait collection.

`previousTraitCollection`

The trait collection prior to the changes that triggered the execution of the handler.

## Discussion

Use [`registerForTraitChanges(_:handler:)`](/documentation/UIKit/UITraitChangeObservable-67e94/registerForTraitChanges(_:handler:)) to register a list of traits to observe and a handler to execute.

If the closure captures a strong reference to the object receiving the registration, it creates a strong reference cycle. Use the `traitEnvironment` parameter to refer to the observed object inside the closure.

---

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)