<!--
{
  "documentType" : "article",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/traits-and-the-trait-environment",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Traits and the trait environment"
}
-->

# Traits and the trait environment

Get information about traits and the environment in which your app runs, and share data with your view hierarchy.

## Overview

Traits represent independent pieces of data that UIKit automatically distributes through your app’s view and view controller hierarchies. The trait system provides a unified way to share configuration information, making it easier to build adaptive interfaces that respond to changes in device orientation, appearance modes, accessibility settings, and custom app states.

The trait system propagates values from the top of the hierarchy downward. When you modify a trait at any level using trait overrides, that change affects the modified object and all of its descendants. Setting a trait override on a window scene affects all view controllers and views within that scene. Setting a trait override on a specific view affects only that view and its subviews.

Use custom traits to propagate data that needs to flow through these parts of your view hierarchy:

- Window scene ([`UIWindowScene`](/documentation/UIKit/UIWindowScene))
- Window ([`UIWindow`](/documentation/UIKit/UIWindow))
- Presentation controller ([`UIPresentationController`](/documentation/UIKit/UIPresentationController))
- View controller ([`UIViewController`](/documentation/UIKit/UIViewController))
- View ([`UIView`](/documentation/UIKit/UIView))
- Subview ([`UIView`](/documentation/UIKit/UIView))

Custom traits are particularly useful for:

- Configuration settings that affect entire sections of your interface
- Appearance states that need to cascade through view hierarchies
- Custom app themes or styling modes
- Feature flags that enable or disable UI elements

Avoid using custom traits in cases where you can directly set properties on a view controller, view, or subview.

## Topics

### Essentials

[Adapting your app when traits change](/documentation/UIKit/adapting-your-app-when-traits-change)

Find out when system changes happen that affect your app, then update your app efficiently.

### Observing and managing traits

[Automatic trait tracking](/documentation/UIKit/automatic-trait-tracking)

Reduce the need to manually register for trait changes when you use traits within a method or closure that supports automatic trait tracking.

[`class UITraitCollection`](/documentation/UIKit/UITraitCollection)

A collection of data that represents the environment for an individual element in your app’s user interface.

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

A set of methods that makes the iOS interface environment available to your app.

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

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

[`protocol UIMutableTraits`](/documentation/UIKit/UIMutableTraits-13ja5)

A mutable container of traits.

[`@protocol UITraitChangeObservable`](/documentation/UIKit/UITraitChangeObservable-7qoet)

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

[`@protocol UIMutableTraits <NSObject>`](/documentation/UIKit/UIMutableTraits-8l00o)

A mutable container of traits.

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

A set of methods that, in conjunction with a presentation controller, determine how to respond to trait changes in your app.

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

A set of methods for adapting the contents of your view controllers to size and trait changes.

### Custom traits

[Providing data to the view hierarchy with custom traits](/documentation/UIKit/providing-data-to-the-view-hierarchy-with-custom-traits)

Share data that needs to flow hierarchically across multiple levels of your view hierarchy.

[`protocol UIMutableTraits`](/documentation/UIKit/UIMutableTraits-13ja5)

A mutable container of traits.

[`typealias UITrait`](/documentation/UIKit/UITrait-9423)

A type representing a trait in a trait collection.

[`protocol UITraitDefinition`](/documentation/UIKit/UITraitDefinition-64c15)

A type representing a trait in a trait collection.

[`typedef Class<UITraitDefinition> * UITrait;`](/documentation/UIKit/UITrait-1dbah)

[`@protocol UITraitDefinition`](/documentation/UIKit/UITraitDefinition-3572h)

A type representing a trait in a trait collection.

[`@protocol UIObjectTraitDefinition <UITraitDefinition>`](/documentation/UIKit/UIObjectTraitDefinition)

[`@protocol UICGFloatTraitDefinition <UITraitDefinition>`](/documentation/UIKit/UICGFloatTraitDefinition)

[`@protocol UINSIntegerTraitDefinition <UITraitDefinition>`](/documentation/UIKit/UINSIntegerTraitDefinition)



---

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)