accessibilityAction

Adds an accessibility action to the view. Actions allow assistive technologies, such as the VoiceOver, to interact with the view by invoking the action.

View ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+

Overloads

3 ways to call compose().accessibilityAction(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().accessibilityAction(
  actionKind: SwiftUI.AccessibilityActionKind | undefined,
  handler: () => void
)
Swift
nonisolated func accessibilityAction(
    _ actionKind: AccessibilityActionKind = .default,
    _ handler: @escaping () -> Void
) -> ModifiedContent<Self, AccessibilityAttachmentModifier>

Parameters

Discussion

For example, this is how a .default action to compose a new email could be added to a view.

var body: some View {
    ContentView()
        .accessibilityAction {
            // Handle action
        }
}

See also

More in Accessibility.