Contents

accessibilityTraits

The combination of traits that best characterize the accessibility element.

Declaration

var accessibilityTraits: UIAccessibilityTraits { get set }

Discussion

A trait describes a single aspect of an element’s behavior, state, or usage. Several traits are combined in this property (using an OR operation) to give a complete picture of the element to an assistive application. See “Accessibility Traits” in UIAccessibility for a complete list of traits.

UIKit provides an appropriate combination of traits for all standard controls and views. When combining traits for a custom accessibility element, be sure to:

  • Use common sense. Don’t combine traits that characterize the element in mutually exclusive ways, such as combining the button and search-field traits.

  • Combine the traits you select with the superclass’s traits. Specifically, always combine your custom traits with [super accessibilityTraits] in the method you use to set a custom element’s traits.

See Also

Accessing the attributes of an accessibility element