Accessibility state on iOS
An accessibility state helps users of assistive technologies to understand the state of elements on the screen. The state selected
for example, indicates that an element has been selected. The screen reader announces the state of elements as it reads the screen. It is important to assign correct states of elements to avoid misunderstanding.
On iOS, the accessibilityTraits
attribute can be used to indicate the accessibility state. The traits selected
and notEnabled
can be used to indicate the current state.
If your state is not selected
or notEnabled
, we recommended using the accessibilityValue
attribute to indicate the state.
element.accessibilityTraits = .selected
element.accessibilityTraits = .notEnabled
element.accessibilityValue = "Expanded"
element.accessibilityValue = "Collapsed"