How do I top align a Form
within a NavigationView
. I have the below, when I remove NaviagationView
from the body, the Form
is top aligned. With NavigationView
in place, I get spacing in between(red box added to show space). I can use .padding(.top, -20)
on the Form but while this works it skews things slightly.
NavigationView {
Form {
VStack {
HStack {
Text("Name:").underline().font(.headline)
TextField("Name", text: $routine.name)
}
roundPicker()
TimeSelectionView(stateName: "A", stateDuration: "0:30", stateBackground: "#df405a")
TimeSelectionView(stateName: "B", stateDuration: "1:30", stateBackground: "#4ea1d3")
TimeSelectionView(stateName: "C", stateDuration: "3:00", stateBackground: "#4f953b")
}
}
.navigationBarTitle("Create", displayMode: .inline)
.navigationBarItems(trailing:
Button(action: {
//Save Routine
self.routine.rounds = self.roundsArray[self.rounds]
print("Workout Name: \(self.routine.name)")
print("Workout Rounds: \(self.routine.rounds)")
}, label: {
Text("Save")
}
)
)
}
.listStyle(GroupedListStyle())
to aList
view and the accepted answer also works in that case. – Teo Sartori