Why does my Spacer() between Text and Stepper not work in the code below?
Here is how it looks like:
Here is how I would like it to look like:
import SwiftUI
struct FontEditView: View {
@Binding var fontSize: CGFloat
var body: some View {
NavigationStack {
Form {
HStack {
Text("Font Size")
Spacer()
Stepper(fontSize.formatted(), value: $fontSize, in: 5...50)
}
}
}
}
}
struct FontEditView_Previews: PreviewProvider {
static var previews: some View {
FontEditView(fontSize: .constant(20))
}
}
CodePudding user response:
Just add .fixedSize()
to the Stepper
Fixes this view at its ideal size.
Stepper(fontSize.formatted(), value: $fontSize, in: 5...50)
.fixedSize()