I am trying to add accessibility to our swift code- for automation purposes The end goal is to tap on a button, that has a unique identifier.
current implementation looks like:
var body: some View {
NavigationView {
ZStack {
VStack {
HStack{
Picker(selection: _ , label: Text("")) {
Image(systemName: "list.bullet").tag().accessibility(identifier: "list")
Image(systemName: "square.grid.3x2.fill").tag().accessibility(identifier: "grid")
}
.pickerStyle(SegmentedPickerStyle())
}
}
}
}
}
I believe when the .pickerStyle gets converted into segmented control, and the Images become Buttons, xcode removes all accessibility traits. The console output of app looks like:
SegmentedControl, 0x60000121e4c0, {{668.0, 90.0}, {150.0, 32.0}}
Button, 0x60000121e5a0, {{668.0, 90.0}, {74.0, 32.0}}, Selected
Button, 0x60000121e680, {{743.0, 90.0}, {75.0, 32.0}}
In other areas, Image with .accessibility(identifier: "") works perfectly, so it has to have something to do with pickerStyle.
I've also tried this attributes for accessibility:
.accessibility(hidden: false)
.accessibility(label: "")
.accessibility(value: "")
Does anyone know how to work around this? So that in the end, the debugger could print:
SegmentedControl, 0x60000121e4c0, {{668.0, 90.0}, {150.0, 32.0}}
Button, 0x60000121e5a0, {{668.0, 90.0}, {74.0, 32.0}}, identifier: 'list', Selected
Button, 0x60000121e680, {{743.0, 90.0}, {75.0, 32.0}}, identifier: 'grid'