Skip to content

Instantly share code, notes, and snippets.

@iosdevie
Created May 29, 2021 20:29
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 iosdevie/8725467850715e1bff2721bc6752083a to your computer and use it in GitHub Desktop.
Save iosdevie/8725467850715e1bff2721bc6752083a to your computer and use it in GitHub Desktop.
struct ContentView: View {
@GestureState private var didLongPress: Bool = false
var body: some View {
Rectangle()
.foregroundColor(Color.purple)
.cornerRadius(40)
.scaleEffect(didLongPress ? 1.2 : 1)
.frame(width: 200, height: 200, alignment: .center)
.gesture(LongPressGesture(minimumDuration: 1.0)
.updating($didLongPress) { value, state, transcation in
state = value})
.animation(.easeInOut)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment