Last active
June 8, 2022 10:15
-
-
Save darrarski/c9e7e1e3fa8ddde778fd141d651f01eb to your computer and use it in GitHub Desktop.
Get location of a tap in SwiftUI
This file contains hidden or 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
import SwiftUI | |
struct ExampleView: View { | |
var body: some View { | |
Color.blue | |
.gesture( | |
TapGesture(count: 1) | |
.simultaneously(with: DragGesture(minimumDistance: 0)) | |
.onEnded { value in | |
if value.first != nil, let location = value.second?.startLocation { | |
print("did tap location: \(location)") | |
} | |
} | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment