When using a Picker
with .pickerStyle(WheelPickerStyle())
, the horizontal space that the picker takes up is seemingly fixed. In the image below, the Picker frame (which is seen by its lighter color) is larger than it needs to be for its elements.
I'm trying to get the picker to only be as wide as it needs to be for the longest option it contains, similar to how Text()
views "wrap" their text, and are only as big as the text inside them requires them to be.
How can I accomplish this for a Wheel Picker in SwiftUI?