From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

SwiftUI swipe gesture

SwiftUI swipe gesture

- [Instructor] While you may have mastered ONTAP for gestures and SwiftUI, the other gestures are not as intuitive. Let's look at the Drag Gestures to show you some of the parts of a good gesture in SwiftUI. In the exercise file, we have a simple app that has a value in a text field. We're going to add a Drag Gesture to this view so we can change that value. So first I'm going to change my value that I have in the state to a CGFloat, because that's what gestures use. And then I'm going to go down a little further in my code, and you'll see in here, I've got a return VStack, and that allows me to put extra code in the body. So I don't have to worry about the Stack anymore and getting it all returned properly. So we're going to put right inside of the body here a variable. Let drag equal DragGesture. And Drag Gestures have some modifiers, which like its UIKit counterparts have the changed and end state of the gesture.…

Contents