Skip to content

Instantly share code, notes, and snippets.

@manojkarki
Created July 4, 2020 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manojkarki/56e0a30e0dafb565055b906e169ddf90 to your computer and use it in GitHub Desktop.
Save manojkarki/56e0a30e0dafb565055b906e169ddf90 to your computer and use it in GitHub Desktop.
/*
Tapping on top button will tap the buttons inside srollview!!!
Fix: Adding zOrder solved the problem
*/
struct TapGoingBehind: View {
@State
var tapMeCount = 0
@State
var rectangleTapCount = 0
var body: some View {
VStack (spacing: 5) {
Text("Tap Me count \(tapMeCount)")
.padding()
Text("Rectangle Tap Count \(rectangleTapCount)")
.padding()
Button {
self.tapMeCount += 1
} label: {
Text("Tap Me")
.padding(10)
}
.padding()
ScrollView([.vertical]) {
VStack(spacing: 0) {
ForEach(0 ..< 20, id: \.self) { row in
Button {
self.rectangleTapCount += 1
} label: {
RoundedRectangle(cornerRadius: 10)
.fill(Color.green)
.frame(width: 200, height: 400)
}
}
}
}
.padding(10)
.border(Color.red, width: 5)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment