Overloads
4 ways to call compose().accessibilityRotor(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().accessibilityRotor<EntryModel>(
rotorLabelResource: string,
options: {
entries: EntryModel[];
entryID: string;
entryLabel: string;
}
)@export(implementation) nonisolated func accessibilityRotor<EntryModel, ID>(
_ rotorLabelResource: LocalizedStringResource,
entries: [EntryModel],
entryID: KeyPath<EntryModel, ID>,
entryLabel: KeyPath<EntryModel, String>
) -> some View
where ID : Hashable3 more Swift overloads share this form
nonisolated func accessibilityRotor<EntryModel, ID>(
_ rotorLabelKey: LocalizedStringKey,
entries: [EntryModel],
entryID: KeyPath<EntryModel, ID>,
entryLabel: KeyPath<EntryModel, String>
) -> some View
where ID : Hashablenonisolated func accessibilityRotor<EntryModel, ID>(
_ rotorLabel: Text,
entries: [EntryModel],
entryID: KeyPath<EntryModel, ID>,
entryLabel: KeyPath<EntryModel, String>
) -> some View
where ID : Hashablenonisolated func accessibilityRotor<L, EntryModel, ID>(
_ rotorLabel: L,
entries: [EntryModel],
entryID: KeyPath<EntryModel, ID>,
entryLabel: KeyPath<EntryModel, String>
) -> some View
where L : StringProtocol, ID : HashableParameters
rotorLabelResource*stringLocalized label identifying this Rotor to the user.
options.entries*EntryModel[]An array of values that will be used to generate the entries of the Rotor.
options.entryID*stringKey path on the entry type that can be used to generate an identifier for the Entry. The identifiers must match up with identifiers in
ForEachor explicitidcalls within theScrollView.options.entryLabel*stringKey path on the entry type that can be used to get a user-visible label for every Rotor entry. This is used on macOS when the user opens the list of entries for the Rotor.
Discussion
An Accessibility Rotor is a shortcut for Accessibility users to quickly navigate to specific elements of the user interface, and optionally specific ranges of text within those elements.
Using this modifier requires that the Rotor be attached to a
ScrollView, or an Accessibility Element directly within a
ScrollView, such as a ForEach. When the user navigates to entries
from this Rotor, SwiftUI will automatically scroll them into place as
needed.
In the following example, a Message application creates a Rotor allowing users to navigate to specifically the messages originating from VIPs.
// `messages` is a list of `Message`s that have a `subject` and a
// `uuid`. `vipMesages` is a filtered version of that list
// containing only messages from VIPs.
ScrollView {
LazyVStack {
ForEach(messages) { message in
MessageView(message)
}
}
}
.accessibilityElement(children: .contain)
.accessibilityRotor("VIPs", entries: vipMessages,
entryID: \.uuid, entryLabel: \.subject)See also
More in Accessibility.
- accessibilityActionAdds an accessibility action to the view. Actions allow assistive technologies, such as the VoiceOver, to interact with the view by invoking the action.
- accessibilityActionsAdds multiple accessibility actions to the view.
- accessibilityActivationPointThe activation point for an element is the location assistive technologies use to initiate gestures.
- accessibilityAddTraitsAdds the given traits to the view.
- accessibilityAdjustableActionAdds an accessibility adjustable action to the view. Actions allow assistive technologies, such as the VoiceOver, to interact with the view by invoking the action.
- accessibilityChildrenReplaces the existing accessibility element's children with one or more new synthetic accessibility elements.
- accessibilityCustomContentAdd additional accessibility information to the view.
- accessibilityDefaultFocusDefines a region in which default accessibility focus is evaluated by assigning a value to a given accessibility focus state binding.
- accessibilityDirectTouchExplicitly set whether this accessibility element is a direct touch area. Direct touch areas passthrough touch events to the app rather than being handled through an assistive technology, such as VoiceOver. The modifier accepts an optional AccessibilityDirectTouchOptions option set to customize the functionality of the direct touch area.
- accessibilityDragPointThe point an assistive technology should use to begin a drag interaction.
- accessibilityDropPointThe point an assistive technology should use to end a drag interaction.
- accessibilityElementCreates a new accessibility element, or modifies the AccessibilityChildBehavior of the existing accessibility element.