Skip to main content
Logo Appt Light

Accessibility role on iOS

An accessibility role helps users of assistive technologies to understand the purpose of elements on the screen. The role button for example, indicates that an action will be performed on activation. The screen reader announces the role of elements as it reads the screen. It is important to assign correct roles to elements to avoid misunderstanding.

On iOS, the accessibilityTraits attribute is used to indicate an accessibility role. The UIAccessibilityTraits structure contains all options, such as header, button, link and image, among others.

You can also combine multiple traits. For example, for a selected button you can can pass both traits as an array: [.button, .selected].

element.accessibilityTraits = .button
element.accessibilityTraits = .header
element.accessibilityTraits = .link
element.accessibilityTraits = .image

element.accessibilityTraits = [.button, .selected]

Feedback?

Let us know!