How do I change the Picker Frame in SwiftUI?
Picker(selection: .constant(1), label: Text("Picker")) {
Text("Hello").tag(1)
Text("World").tag(2)
}
.frame(height: 60)
.pickerStyle(SegmentedPickerStyle())
We expect the picker height to equal 60
, but it doesn't.
There is no direct way to change the height of the SegmentedPickerStyle
picker but we can scale it using the following code.
Picker(selection: .constant(1), label: Text("Picker")) {
Text("Hello").tag(1)
Text("World").tag(2)
}
.frame(height: 60)
.pickerStyle(SegmentedPickerStyle())
.scaledToFit()
.scaleEffect(CGSize(width: 1.5, height: 1.5))
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