Hello I have a Drag Gesture function. You can see what this function is for by looking at the code.
My problem is this: I just want the view to move down to a certain extent. How can I do that?
func onChanged(value: DragGesture.Value){
if value.startLocation.y < value.location.y {
playerModel.offset = value.translation
let screenHeight = UIScreen.main.bounds.width - 50
let progress = playerModel.offset.height / screenHeight
if 1 - progress > 0.925 {
playerModel.scale = 1 - progress
}
}
}
2
Answers
Here’s an example of how to limit movement of a draggable rectangle that recognizes device rotation and doesn’t use GeometryReader.
Try this: