Accessibility label on iOS
An accessibility label helps users of assistive technologies to identify elements on the screen. The accessibility label is conveyed to assistive technologies. Accessibility labels are announced by the screen reader and presented visually by voice control.
On iOS, you can use the
accessibilityLabel property to set an accessibility label.
You can also use the
attributedAccessibilityLabel property for greater control over pronunciation. For example, spell out each character with
.accessibilitySpeechPunctuation or set a language using
The accessibility label should be as short as possible, while still being intuitive. When long labels cannot be avoided, you should use
accessibilityUserInputLabels to provide alternative labels. The primary label is first in the array, optionally followed by alternative labels in descending order of importance.
If another element is used to display the label, you can link the label by setting
false and setting
accessibilityLabel to the
value of the label.
// Set accessibility label element.accessibilityLabel = "Appt" // Set accessibility label with Dutch speech engine element.attributedAccessibilityLabel = NSAttributedString( string: "Appt", attributes: [.accessibilitySpeechLanguage: "nl-NL"] ) // Set accessibility label for controls element.accessibilityUserInputLabels = ["Appt", "Alternative"] // Link visual label label.isAccessibilityElement = false element.accessibilityLabel = label.text