I have a problem with the display of a picker within “Form”.
I enter the following code
import SwiftUI
struct ContentView: View {
@State var myPickerSelection = 1.0
var body: some View {
Form {
HStack {
Text("My parameter")
Spacer(minLength: 100)
Slider(value: $myPickerSelection, in: 0.0...1.0,
label: { Text("\(myPickerSelection, specifier: "%.2f")") })
.padding()
}
}
.padding()
}
}
so the appearance is correct in my opinion.
The label is near the Picker
But if I enter the code with the “.grouped” option
import SwiftUI
struct ContentView: View {
@State var myPickerSelection = 1.0
var body: some View {
Form {
HStack {
Text("My parameter")
Spacer(minLength: 100)
Slider(value: $myPickerSelection, in: 0.0...1.0,
label: { Text("\(myPickerSelection, specifier: "%.2f")") })
.padding()
}
}
.formStyle(.grouped)
.padding()
}
}
The “picker-label” has a distance to the picker-display
How can this be fixed. I have no idea, unless I implement an “HSTack” like the individual components get a fixed size (”.frame(with: ...)”
Are there any other ideas?