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

# UITraitChangeObservable

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

```
@MainActor protocol UITraitChangeObservable
```

## Overview

Types that conform to [`UITraitChangeObservable`](/documentation/UIKit/UITraitChangeObservable-67e94) 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

[`registerForTraitChanges(_:action:)`](/documentation/UIKit/UITraitChangeObservable-67e94/registerForTraitChanges(_:action:))

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

[`registerForTraitChanges(_:handler:)`](/documentation/UIKit/UITraitChangeObservable-67e94/registerForTraitChanges(_:handler:))

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

[`registerForTraitChanges(_:target:action:)`](/documentation/UIKit/UITraitChangeObservable-67e94/registerForTraitChanges(_:target:action:))

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

[`unregisterForTraitChanges(_:)`](/documentation/UIKit/UITraitChangeObservable-67e94/unregisterForTraitChanges(_:))

Tells the system to stop observing previously registered traits.

[`TraitChangeHandler`](/documentation/UIKit/UITraitChangeObservable-67e94/TraitChangeHandler)

A closure the system executes when observed traits change.

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

### Registering traits for observation

[`UITraitAccessibilityContrast`](/documentation/UIKit/UITraitAccessibilityContrast-swift.struct)

A struct that represents the accessibility contrast setting trait.

[`UITraitActiveAppearance`](/documentation/UIKit/UITraitActiveAppearance-swift.struct)

A struct that represents the active appearance trait.

[`UITraitDisplayGamut`](/documentation/UIKit/UITraitDisplayGamut-swift.struct)

A struct that represents the display gamut trait.

[`UITraitDisplayScale`](/documentation/UIKit/UITraitDisplayScale-swift.struct)

A struct that represents the display scale trait.

[`UITraitForceTouchCapability`](/documentation/UIKit/UITraitForceTouchCapability-swift.struct)

A struct that represents the Force Touch capability trait.

[`UITraitHDRHeadroomUsageLimit`](/documentation/UIKit/UITraitHDRHeadroomUsageLimit-swift.struct)

A struct that represents the HDR headroom usage limit trait.

[`UITraitHorizontalSizeClass`](/documentation/UIKit/UITraitHorizontalSizeClass-swift.struct)

A struct that represents the horizontal size class trait.

[`UITraitImageDynamicRange`](/documentation/UIKit/UITraitImageDynamicRange-swift.struct)

A struct that represents the image dynamic range trait.

[`UITraitLayoutDirection`](/documentation/UIKit/UITraitLayoutDirection-swift.struct)

A struct that represents the layout direction trait.

[`UITraitLegibilityWeight`](/documentation/UIKit/UITraitLegibilityWeight-swift.struct)

A struct that represents the legibility weight trait.

[`UITraitListEnvironment`](/documentation/UIKit/UITraitListEnvironment-swift.struct)

A struct that represents the list environment trait.

[`UITraitPreferredContentSizeCategory`](/documentation/UIKit/UITraitPreferredContentSizeCategory-swift.struct)

A struct that represents the preferred content size category trait.

[`UITraitResolvesNaturalAlignmentWithBaseWritingDirection`](/documentation/UIKit/UITraitResolvesNaturalAlignmentWithBaseWritingDirection-swift.struct)

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

[`UITraitSceneCaptureState`](/documentation/UIKit/UITraitSceneCaptureState-swift.struct)

A struct that represents the scene capture state trait.

[`UITraitSplitViewControllerLayoutEnvironment`](/documentation/UIKit/UITraitSplitViewControllerLayoutEnvironment-swift.struct)

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

[`UITraitTabAccessoryEnvironment`](/documentation/UIKit/UITraitTabAccessoryEnvironment-swift.struct)

A struct that represents tab accessory environment trait.

[`UITraitToolbarItemPresentationSize`](/documentation/UIKit/UITraitToolbarItemPresentationSize-swift.struct)

A struct that represents the toolbar item presentation size trait.

[`UITraitTypesettingLanguage`](/documentation/UIKit/UITraitTypesettingLanguage-swift.struct)

A struct that represents the typesetting language trait.

[`UITraitUserInterfaceIdiom`](/documentation/UIKit/UITraitUserInterfaceIdiom-swift.struct)

A struct that represents the user interface idiom trait.

[`UITraitUserInterfaceLevel`](/documentation/UIKit/UITraitUserInterfaceLevel-swift.struct)

A struct that represents the user interface level trait.

[`UITraitUserInterfaceStyle`](/documentation/UIKit/UITraitUserInterfaceStyle-swift.struct)

A struct that represents the user interface style trait.

[`UITraitVerticalSizeClass`](/documentation/UIKit/UITraitVerticalSizeClass-swift.struct)

A struct that represents the vertical size class trait.

## Relationships

### Conforming Types

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

---

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)