Discussion 議論
Use this behavior when you want a view to be an accessibility container. An accessibility container groups child accessibility elements which improves navigation. For example, all children of an accessibility container are navigated in order before navigating through the next accessibility container.
var body: some View {
ScrollView {
VStack {
HStack {
ForEach(users) { user in
UserCell(user)
}
}
.accessibilityElement(children: .contain)
.accessibilityLabel("Users")
VStack {
ForEach(messages) { message in
MessageCell(message)
}
}
.accessibilityElement(children: .contain)
.accessibilityLabel("Messages")
}
}
}
A new accessibility element is created when:
The view contains multiple or zero accessibility elements
The view contains a single accessibility element with no children
Note 注意
If an accessibility element is not created, the Accessibility
of the existing accessibility element is modified.