SwiftUI Accessibility: Traits

Button(action: {}, label: { Text(“Button”) })
.accessibility(addTraits: [.isSelected, .playsSound])
.accessibility(removeTraits: .isButton)

isButton

isHeader

isSelected

isLink

isSearchField

isImage

playsSound

isKeyboardKey

isStaticText

isSummaryElement

Apple’s Weather app with VoiceOver highlighting the top Summary Element.
Apple’s Weather app with VoiceOver highlighting the top Summary Element.

updatesFrequently

startsMediaSession

allowsDirectInteraction

Apple’s Garage Band app displaying a piano keyboard
Apple’s Garage Band app with VoiceOver highlighting the keyboard view. This view has the trait Allows Direct Interaction allowing multi-touch interaction while still VoiceOver navigation of the controls above the keyboard.

causesPageTurn

isModal

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store