Localized label identifying this Rotor to the user.
accessibilityRotor(_:entries:entryLabel:)
Availability 有効性
- iOS 15.0+
- iPadOS 15.0+
- macOS 12.0+
- Mac Catalyst 15.0+
- tvOS 15.0+
- watchOS 8.0+
Technology
- Swift
UI
Declaration 宣言
func accessibilityRotor<L, EntryModel>(_ rotorLabel: L, entries: [EntryModel ], entryLabel: KeyPath
<EntryModel , String
>) -> some View
where L : StringProtocol
, EntryModel : Identifiable
Parameters パラメータ
rotorLabel
entries
An array of identifiable values that will be used to generate the entries of the Rotor. The identifiers of the
Identifiable
values must match up with identifiers in aFor
or explicitEach id
calls within theScroll
. When the user navigates to entries from this Rotor, SwiftUI will automatically scroll them into place as needed.View entry
Key path on the
Identifiable
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 Scroll
, or an Accessibility Element directly within a Scroll
, such as a For
.
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 `Identifiable` `Message`s that have a
// `subject`.
// `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, label: \.subject)