Posts

Post not yet marked as solved
1 Replies
1.5k Views
0 I am adding a demo code here of my problem. For this I have created a parent view in which I have 2 child views, I have added "accessibilityElement(children: .combine)" code to the parent view, which combines all the elements while I tap on the view. but I want if the user tap on the parent view then the voiceover should speak all views but if the user taps on a button, then it should separately speak the button. Requirement: If the user taps on the parent view then it should speak all the elements of the view but if the user taps on the button then it should only speak the button, not the full view again. Demo Video link: https://drive.google.com/file/d/1aOuDoTiDizQstfEHiTy-8OoGqXcD_uk0/view?usp=sharing In this video, I want if the user taps on the button it should speak only button, not the full view again. The sample code: import SwiftUI struct ContentView: View { var body: some View { VStack(alignment: .leading, spacing: 10) { topView Button("Show details") { print("Tapped show detail") }.accessibilityElement() .accessibilityLabel(Text("This is show detail")) // I want if user tap on this button separatly then it should only speak the button lable only, not the full content again. bottomView }.accessibilityElement(children: .combine) // By this code it will read the topView, button, and bottomView .padding() } @ViewBuilder private var topView: some View { VStack(alignment: .leading, spacing: 5) { Text("First Text") Text("Second Text") } } @ViewBuilder private var bottomView: some View { VStack(alignment: .leading, spacing: 5) { Text("Third Text") Text("Fourth Text") } } } Requirement: If the user taps on the parent view then it should speak all the elements but if the user taps on the button then it should only speak the button, not the full view again.
Posted Last updated
.