I want to create a view that has a form with a button below it. If I include a form and a button, the button goes to the bottom of the screen.
Is this just a SwiftUI bug? Or am I doing something wrong?
//
// TestFile.swift
// searchparty
//
// Created by Me
//
import SwiftUI
struct TestFile: View {
var body: some View {
VStack {
Form{
Text("Hello, World!")
}
Button("Button") {
print("Button tapped!")
}
}
}
}
struct TestFile_Previews: PreviewProvider {
static var previews: some View {
TestFile()
}
}
An empty
Section
with afooter
will do the job, although you'll want to explicitly set the font, or else thefooter
will change it based on the form footer environment: