我正在尝试创建一个个人资料页面,其中底部有一个带有各种选项的表单。Spacer(但是,当我在 中插入) 时VStack,表单不会像它应该做的那样移动到屏幕底部。我尝试用文本替换表单,效果很好,移动到屏幕底部。所以我假设这与形式有关。
这是我的代码
struct Profile: View {
@Environment(\.presentationMode) var mode: Binding<PresentationMode>
var body: some View {
NavigationView {
VStack {
Image(systemName: "person.crop.circle")
.resizable()
.frame(width: 50, height: 50)
// .padding(.top)
Text("email@email.com")
.font(.title)
Spacer()
Form {
Section {
//menuListItem(image: "gear", label: "Settings")
menuListItem(image: "questionmark.circle", label: "Help") menuListItem(image: "info.circle", label: "About")
}
Section {
HStack {
Spacer()
Button(action: {
UserDefaults.standard.set(false, forKey: "LoggedIn")
UserDefaults.standard.set(nil, forKey: "user_id")
UserDefaults.standard.set(nil, forKey: "school_id")
self.mode.wrappedValue.dismiss()
}) {
Text("Log Out")
.font(.body)
.foregroundColor(.red)
}
Spacer()
} …Run Code Online (Sandbox Code Playgroud)