Trying to set isMomentary
of Picker
SegmentedPickerStyle
in SwiftUI.
UIKit
UISegmentedControl
has a Bool isMomentary
.
Looking for how to achieve the same for SwiftUI
Trying to set isMomentary
of Picker
SegmentedPickerStyle
in SwiftUI.
UIKit
UISegmentedControl
has a Bool isMomentary
.
Looking for how to achieve the same for SwiftUI
Copyright © 2021 Jogjafile Inc.
This is an example of how I handle it. Basically you have your picker set its selection back to whatever default value you want it to be. In this example I have a segmented picker with 5x options from 2 -> 50 miles. I can perform an action after a selection that corresponds to that selection; After which it will return to its default state. You can add a delay or animation to this to make it a bit smoother, but that's outside the scope of this question.
Function
I actually have mine inside of a ViewModel but in this example it's on the view itself. Just be sure to check scope and put it in the right place.