XCode 12 Beta 3 SwiftUI Space 在表单的各个部分之间
XCode 12 Beta 3 SwiftUI Space between sections on a form
如何为以下视图缩小窗体上各个部分之间的间距?
var body: some View {
Form {
Section {
TextField("Name", text: $patient.name, onEditingChanged: { changed in
if !isNewPatient {
isSaveDisabled = false
}
}, onCommit: {
if !isNewPatient {
isSaveDisabled = false
}
})
.validation(patient.nameValidation)
TextField("Surname", text: $patient.surname)
.validation(patient.surnameValidation)
TextField("ID Number", text: $patient.id)
.validation(patient.idValidation)
.validation(patient.idRegexValidation)
.disabled(!self.isNewPatient)
.foregroundColor(isNewPatient ? .black : .gray)
}
Section {
TextField("Street Number and Name", text: $patient.street)
TextField("Suburb", text: $patient.suburb)
TextField("Area Code", text: $patient.postCode)
.validation(patient.postCodeRegexValidation)
}.isHidden(isDependant, remove: true)
Section {
Picker("Medical Aid", selection: $patient.medicalAidName) {
ForEach(medicalAids, id: \.self) {
Text([=12=])
}
}
TextField("Medical Aid Number", text: $patient.medicalAidNo)
}.isHidden(isDependant, remove: true)
Section {
Button("Save") {
if isNewPatient {
if patient.create(moc: moc, isDependant: isDependant, mainID: self.mainID) {
isDependantsActive.toggle()
}
} else {
if patient.update(moc: moc) {
self.presentationMode.wrappedValue.dismiss()
}
}
}.disabled(self.isSaveDisabled)
}
NavigationLink("Dependants", destination:
DependantListView(filter: mainID).environment(\.managedObjectContext, moc), isActive: $isDependantsActive
).disabled(isNewPatient).isHidden(isDependant, remove: true)
}
.onReceive(patient.allRequiredValidation) { validation in
if isNewPatient {
self.isSaveDisabled = !validation.isSuccess
}
}
.navigationBarTitle(title, displayMode: .inline)
}
}
表格是这样的:
我查看了以下答案,但它们是不可接受的:
Spacing between sections in a form
尝试在包含 Form
的视图中添加以下内容
init() {
UITableView.appearance().sectionHeaderHeight = .zero
}
如何为以下视图缩小窗体上各个部分之间的间距?
var body: some View {
Form {
Section {
TextField("Name", text: $patient.name, onEditingChanged: { changed in
if !isNewPatient {
isSaveDisabled = false
}
}, onCommit: {
if !isNewPatient {
isSaveDisabled = false
}
})
.validation(patient.nameValidation)
TextField("Surname", text: $patient.surname)
.validation(patient.surnameValidation)
TextField("ID Number", text: $patient.id)
.validation(patient.idValidation)
.validation(patient.idRegexValidation)
.disabled(!self.isNewPatient)
.foregroundColor(isNewPatient ? .black : .gray)
}
Section {
TextField("Street Number and Name", text: $patient.street)
TextField("Suburb", text: $patient.suburb)
TextField("Area Code", text: $patient.postCode)
.validation(patient.postCodeRegexValidation)
}.isHidden(isDependant, remove: true)
Section {
Picker("Medical Aid", selection: $patient.medicalAidName) {
ForEach(medicalAids, id: \.self) {
Text([=12=])
}
}
TextField("Medical Aid Number", text: $patient.medicalAidNo)
}.isHidden(isDependant, remove: true)
Section {
Button("Save") {
if isNewPatient {
if patient.create(moc: moc, isDependant: isDependant, mainID: self.mainID) {
isDependantsActive.toggle()
}
} else {
if patient.update(moc: moc) {
self.presentationMode.wrappedValue.dismiss()
}
}
}.disabled(self.isSaveDisabled)
}
NavigationLink("Dependants", destination:
DependantListView(filter: mainID).environment(\.managedObjectContext, moc), isActive: $isDependantsActive
).disabled(isNewPatient).isHidden(isDependant, remove: true)
}
.onReceive(patient.allRequiredValidation) { validation in
if isNewPatient {
self.isSaveDisabled = !validation.isSuccess
}
}
.navigationBarTitle(title, displayMode: .inline)
}
}
表格是这样的:
我查看了以下答案,但它们是不可接受的: Spacing between sections in a form
尝试在包含 Form
init() {
UITableView.appearance().sectionHeaderHeight = .zero
}