accessibilityScrollAction

Adds an accessibility scroll 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+accessibilityScrollAction(_:) in SwiftUI

Declaration

React
compose().accessibilityScrollAction(
  handler: (arg0: SwiftUI.Edge) => void
)
Swift
nonisolated func accessibilityScrollAction(
    _ handler: @escaping (Edge) -> Void
) -> ModifiedContent<Self, AccessibilityAttachmentModifier>

Parameters

Discussion

For example, this is how a scroll action to trigger a refresh could be added to a view.

var body: some View {
    ScrollView {
        ContentView()
    }
    .accessibilityScrollAction { edge in
        if edge == .top {
            // Refresh content
        }
    }
}

See also

More in Accessibility.