Protocol

UITraitEnvironment

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

Overview

The iOS interface environment includes traits such as horizontal and vertical size class, display scale, and user interface idiom. To access the trait environment of an object that adopts this protocol, use the traitCollection property. The protocol also provides an overridable method that the system calls when the interface environment changes. Implement this method as part of creating an adaptive iOS app.

For more about trait collections, see UITraitCollection. For the WWDC 2014 presentation on creating adaptive interfaces in iOS, see Building Adaptive Apps with UIKit.

Topics

Accessing a Trait Collection

var traitCollection: UITraitCollection

The trait collection for a view controller (an instance of the UIViewController class or one of its subclasses) or a view (an instance of the UIView class or one of its subclasses).

Required.

Responding to a Change in the Interface Environment

func traitCollectionDidChange(UITraitCollection?)

Called when the iOS interface environment changes.

Required.

See Also

Device Environment

Responding to Changing Display Modes on Apple TV

Change images and resources dynamically when the screen gamut on your device changes.

class UIDevice

A representation of the current device.

class UITraitCollection

The iOS interface environment for your app, defined by traits such as horizontal and vertical size class, display scale, and user interface idiom.

protocol UIAdaptivePresentationControllerDelegate

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