I have vstack it has tap gesture to print “view”. Inside vstack two components are there one is back button and tabView, and inside tabView next button is there. on pressing on back button it is printing “back” but on pressing on next button it is printing next and view.
import SwiftUI
struct ContentView: View {
var body: some View {
VStack(spacing: 10) {
Button("Back") {
print("back")
}
TabView {
Button("Next") {
print("next")
}
}
.background(Color.green)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.red)
.onTapGesture {
print("Hello")
}
}
}
#Preview {
ContentView()
}
On pressing on next button, it should print next alone