Hi Rob
Thanks for this article, it was a real help for us when starting with accessibility in SwiftUI.
Did you have any success using .isModal? When trying to create a ViewModifier to present custom Views modally it doesn't seem to work for us (the underlying view is still accessible for VoiceOver.
Here's our ViewModifier implementation:
public extension View {
func modal<ModalView: View>(isPresented: Binding<Bool>, @ViewBuilder modalBody: () -> ModalView) -> some View {
ZStack {
self
.overlay(isPresented.wrappedValue ? Color.black.opacity(0.5) : Color.clear)
.onTapGesture {
isPresented.wrappedValue = false
}
if isPresented.wrappedValue {
modalBody()
.accessibility(addTraits: .isModal)
}
}
}
}