Modify ProgressView with drag gestures in SwiftUI

439 Views Asked by At

Any idea how to modify (if is possible) a ProgressView with drag gestures. To begin with, I think the code will be something like this:

ProgressView(value: progress)
  .gesture(DragGesture()
        .onChanged({ 

              // code here

        })

But I'm really lost. Any help?

1

There are 1 best solutions below

0
sheldor On

The .onChanged modifier has a parameter in the closure. You can do something like:

.onChanged{ val in
    progress = val.translation.width / 100 // perhaps cut it so the number is between 0 and 1
}