combine
Any child accessibility element’s properties are merged into the new accessibility element.
Declaration
static let combine: AccessibilityChildBehaviorDiscussion
Use this behavior when you want a view represented by a single accessibility element. The new accessibility element merges properties from all non-hidden children. Some properties may be transformed or ignored to achieve the ideal combined result. For example, not all of AccessibilityTraits are merged and a default action may become a named action (init(named:)).
struct UserCell: View {
var user: User
var body: some View {
VStack {
Image(user.image)
Text(user.name)
Button("Options", action: showOptions)
}
.accessibilityElement(children: .combine)
}
}A new accessibility element is created when:
The view contains multiple or zero accessibility elements
The view wraps a UIViewRepresentable/NSViewRepresentable.