Created
October 17, 2019 09:00
-
-
Save Amzd/4ed2ca32933d33e64ab91619e30bbdb6 to your computer and use it in GitHub Desktop.
Tap gesture on Spacer
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
extension Spacer { | |
/// https://stackoverflow.com/a/57416760/3393964 | |
public func onTapGesture(count: Int = 1, perform action: @escaping () -> Void) -> some View { | |
ZStack { | |
Color.black.opacity(0.001).onTapGesture(count: count, perform: action) | |
self | |
} | |
} | |
} |
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
Spacer().onTapGesture { | |
// This will activate now | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why self is required inside ZStack? (Line number 6)