<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITraitChangeObservable-7qoet",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITraitChangeObservable"
  },
  "title" : "UITraitChangeObservable"
}
-->

# UITraitChangeObservable

A type that calls your code in reaction to changes in the trait environment.

```
@protocol UITraitChangeObservable
```

## Overview

Types that conform to `UITraitChangeObservable` can execute your code in response to changes in their trait collection. When you register for trait changes, the system observes the specified traits, and calls your code when any of the observed traits change value.

Keep your trait registrations focused, and avoid doing work not directly relevant to updated traits. Traits may change more than once before the system updates a view, so avoid expensive work in response to trait changes. For example, use the trait change notification to call [`setNeedsDisplay()`](/documentation/UIKit/UIView/setNeedsDisplay()), and update your view in [`draw(_:)`](/documentation/UIKit/UIView/draw(_:)).

UIKit cleans up registrations at the end of the object lifecycle. Unregister only in the rare situations when you need to dynamically change which traits you observe.

## Topics

### Observing trait changes

[`- (id<UITraitChangeRegistration>) registerForTraitChanges:(NSArray<Class<UITraitDefinition>> *) traits withAction:(SEL) action;`](/documentation/UIKit/UITraitChangeObservable-7qoet/registerForTraitChanges:withAction:)

Registers a list of traits to observe, and calls a method on the receiving object when one of the observed traits changes.

[`- (id<UITraitChangeRegistration>) registerForTraitChanges:(NSArray<Class<UITraitDefinition>> *) traits withHandler:(UITraitChangeHandler) handler;`](/documentation/UIKit/UITraitChangeObservable-7qoet/registerForTraitChanges:withHandler:)

Registers a list of traits to observe and a closure to execute when one of the observed traits changes.

[`- (id<UITraitChangeRegistration>) registerForTraitChanges:(NSArray<Class<UITraitDefinition>> *) traits withTarget:(id) target action:(SEL) action;`](/documentation/UIKit/UITraitChangeObservable-7qoet/registerForTraitChanges:withTarget:action:)

Registers a list of traits to observe, and calls a method on the specified target object when one of the observed traits changes.

[`- (void) unregisterForTraitChanges:(id<UITraitChangeRegistration>) registration;`](/documentation/UIKit/UITraitChangeObservable-7qoet/unregisterForTraitChanges:)

Tells the system to stop observing previously registered traits.

[`typedef void (^)(__kindof id<UITraitEnvironment>, UITraitCollection *) UITraitChangeHandler;`](/documentation/UIKit/UITraitChangeHandler)

[`protocol UITraitChangeRegistration`](/documentation/UIKit/UITraitChangeRegistration)

### Registering traits for observation

[`@interface UITraitAccessibilityContrast : NSObject`](/documentation/UIKit/UITraitAccessibilityContrast-c.class)

A class that represents the accessibility contrast setting trait.

[`@interface UITraitActiveAppearance : NSObject`](/documentation/UIKit/UITraitActiveAppearance-c.class)

A class that represents the active appearance trait.

[`@interface UITraitDisplayGamut : NSObject`](/documentation/UIKit/UITraitDisplayGamut-c.class)

A class that represents the display gamut trait.

[`@interface UITraitDisplayScale : NSObject`](/documentation/UIKit/UITraitDisplayScale-c.class)

A class that represents the display scale trait.

[`@interface UITraitForceTouchCapability : NSObject`](/documentation/UIKit/UITraitForceTouchCapability-c.class)

A class that represents the Force Touch capability trait.

[`@interface UITraitHDRHeadroomUsageLimit : NSObject`](/documentation/UIKit/UITraitHDRHeadroomUsageLimit-c.class)

A class that represents the HDR headroom usage limit trait.

[`@interface UITraitHorizontalSizeClass : NSObject`](/documentation/UIKit/UITraitHorizontalSizeClass-c.class)

A class that represents the horizontal size class trait.

[`@interface UITraitImageDynamicRange : NSObject`](/documentation/UIKit/UITraitImageDynamicRange-c.class)

A class that represents the image dynamic range trait.

[`@interface UITraitLayoutDirection : NSObject`](/documentation/UIKit/UITraitLayoutDirection-c.class)

A class that represents the layout direction trait.

[`@interface UITraitLegibilityWeight : NSObject`](/documentation/UIKit/UITraitLegibilityWeight-c.class)

A class that represents the legibility weight trait.

[`@interface UITraitListEnvironment : NSObject`](/documentation/UIKit/UITraitListEnvironment-c.class)

A class that represents the list environment trait.

[`@interface UITraitPreferredContentSizeCategory : NSObject`](/documentation/UIKit/UITraitPreferredContentSizeCategory-c.class)

A class that represents the preferred content size category trait.

[`@interface UITraitResolvesNaturalAlignmentWithBaseWritingDirection : NSObject`](/documentation/UIKit/UITraitResolvesNaturalAlignmentWithBaseWritingDirection-c.class)

A class that represents the trait that indicates whether the system resolves natural alignment with base writing direction.

[`@interface UITraitSceneCaptureState : NSObject`](/documentation/UIKit/UITraitSceneCaptureState-c.class)

A class that represents the scene capture state trait.

[`@interface UITraitSplitViewControllerLayoutEnvironment : NSObject`](/documentation/UIKit/UITraitSplitViewControllerLayoutEnvironment-c.class)

A class that represents the split view controller layout environment trait.

[`@interface UITraitTabAccessoryEnvironment : NSObject`](/documentation/UIKit/UITraitTabAccessoryEnvironment-c.class)

A class that represents the tab accessory environment trait.

[`@interface UITraitToolbarItemPresentationSize : NSObject`](/documentation/UIKit/UITraitToolbarItemPresentationSize-c.class)

A class that represents the toolbar item presentation size trait.

[`@interface UITraitTypesettingLanguage : NSObject`](/documentation/UIKit/UITraitTypesettingLanguage-c.class)

A class that represents the typesetting language trait.

[`@interface UITraitUserInterfaceIdiom : NSObject`](/documentation/UIKit/UITraitUserInterfaceIdiom-c.class)

A class that represents the user interface idiom trait.

[`@interface UITraitUserInterfaceLevel : NSObject`](/documentation/UIKit/UITraitUserInterfaceLevel-c.class)

A class that represents the user interface level trait.

[`@interface UITraitUserInterfaceStyle : NSObject`](/documentation/UIKit/UITraitUserInterfaceStyle-c.class)

A class that represents the user interface style trait.

[`@interface UITraitVerticalSizeClass : NSObject`](/documentation/UIKit/UITraitVerticalSizeClass-c.class)

A class that represents the vertical size class trait.

## Relationships

### Conforming Types

[`UIWindowScene`](/documentation/UIKit/UIWindowScene)

[`UIViewController`](/documentation/UIKit/UIViewController)

[`UIView`](/documentation/UIKit/UIView)

[`UIPresentationController`](/documentation/UIKit/UIPresentationController)

---

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)