Is it possible to set a placeholder text for a Swift Picker? I've been trying to search for a helpful answer but I haven't been successful so far.
Currently, when passing available list values to the Picker, I also pass it a default value to start with. However, this default value is treated the same as if the user picked it. What I'm trying to achieve is that the default value should be grayed out (like regular placeholders for standard textfields) and when the user opens the picker that value would 'disappear' as default forcing the user to pick something from the list (but without losing the range) -
So for example, if I have a picker for values between 1-200 and I set my placeholder to 100 the picker would still show this value when you open it (to avoid scrolling from the beginning) but it wouldn't be directly taken as the target value unless the user actually selects it.
A Menu may be a better option than a Picker in this instance.
Menu("Label") {
Button("Menu Item", action: menuAction)
Button("Other Menu Item", action: otherMenuAction)
}
Menu Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With