SwiftUI Basics: How to Implement a LongPressGesture
Create a spring animation utilizing LongPressGesture & Gesture State Property Wrapper
Published in
3 min readMay 23, 2020
The LongPressGesture
is a gesture that is initiated after a user performs a long-press action.
Objectives
- Create a
LongPressGesture
animation utilizing@State
andGestureState
property wrapper types.
Create a @State
variable that declares a scale factor for your destined View
.
@State private var scaleFactor: CGFloat = 1
Create an object you want to manipulate–e.g., Image, Rectangle, etc. We will use an Image.
You should be met with the following. Shoutout to @danny_lincoln for giving our project a much-needed splash of color!
Next, we will be adding our gesture. Gestures take the parameters of…