UITraitEnvironment
A set of methods that makes the iOS interface environment available to your app.
Declaration
@MainActor protocol UITraitEnvironment : NSObjectProtocolMentioned in
Overview
The system represents the iOS interface environment with traits, such as horizontal and vertical size class, display scale, and user interface idiom. You access the trait environment of an object that adopts this protocol with the traitCollection property.
The trait system propagates values from the top of the view hierarchy downward, to every view controller and view in your app. When you modify a trait at any level using trait overrides, that change affects the modified object and all of its descendants. This hierarchical propagation makes it easy to apply configuration changes to entire subtrees of your interface.
For example, setting a trait override on a window scene affects all view controllers and views within that scene. Similarly, setting a trait override on a specific view affects only that view and its subviews.
For more information about how traits propagate through the system, see Unleash the UIKit trait system.