Created
July 4, 2020 16:23
-
-
Save manojkarki/56e0a30e0dafb565055b906e169ddf90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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