This is a weird but simple issue that I'm having and I'm hoping someone can figure it out: I have a modal that contains a form and a NavigationView for the navigationTitle and navigationBarItems. However, the form doesn't take up the whole modal, leaving this weird white gap between the navigationBar and form. Is there any way to remove this weird gap? Attached is my code. Thanks!
var body: some View {
// Create Navigation View for the title at the top
NavigationView {
VStack(spacing: 0) {
Text("")
// Navigation Title
.navigationTitle("Modal Title").navigationBarTitleDisplayMode(.inline)
// Creating Cancel Button
.navigationBarItems(leading: Button(action: {
self.isPresented = false
}, label: {
Text("Cancel").frame(maxWidth: .infinity, alignment: .leading)
.frame(alignment: .top)}))
// Creating Add button
.navigationBarItems(trailing: Button(action: {
self.isPresented = false
print("\(self.taskName)")
print("\(self.description)")
}, label: {
Text("Add").frame(maxWidth: .infinity, alignment: .leading)
.frame(alignment: .top)}))
// Creating form for the text fields
Form {
// Section 1: Title and Desctiption text views
Section {
TextField("Title", text: $taskName)
TextField("Description", text: $description)
.ignoresSafeArea()
}
Section {
DatePicker("Date", selection: $date, in: Date()..., displayedComponents: .date)
.datePickerStyle(GraphicalDatePickerStyle())
}
}
}
}
}