I have a Form and a Button in a VStack, but the form takes up nearly the entire view and the button is forced at the bottom. I am trying to make the button come right after the form, but so far my attempts with padding and spacer have failed. Anyone else know how to prevent a form from taking up the entire view?
Asked
Active
Viewed 915 times
2 Answers
0
You have two solutions: 1 - if you know the frame of your form, you can set the frame for the Form and set infinity height for VStack to fill the entire screen
var body: some View {
VStack {
Form {
Text("blah")
}.frame(height: 300)
Button("blubb") { }
}.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
}
2 - embed the Button in Form and separate it using Section
VStack {
Form {
Text("blah")
Section {
Button("blubb") { }
}
}
}

Mac3n
- 4,189
- 3
- 16
- 29