SwiftUI lets us stop a view from receiving any kind of taps using the allowsHitTesting()
modifier.
Example:
struct ContentView: View {
var body: some View {
ZStack {
Button("Tap Me") {
print("Button was tapped")
}
.frame(width: 100, height: 100)
.background(Color.white)
Rectangle()
.fill(Color.red.opacity(0.2))
.frame(width: 300, height: 300)
.clipShape(Circle())
.allowsHitTesting(false)
}
}
}