Overloads
2 ways to call compose().listSectionSpacing(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().listSectionSpacing(spacing: number)nonisolated func listSectionSpacing(_ spacing: CGFloat) -> some ViewParameters
spacing*numberthe amount of spacing to apply.
Discussion
The following example creates a List with 5 pts of spacing between
sections:
List {
Section("Colors") {
Text("Blue")
Text("Red")
}
Section("Shapes") {
Text("Square")
Text("Circle")
}
}
.listSectionSpacing(5.0)Spacing can also be specified on an individual Section, as in this
example:
Section("Borders") {
Text("Dashed")
Text("Solid")
}
.listSectionSpacing(10.0)If adjacent sections have different spacing applied, each section applies half its spacing above and below. Sections without explicit spacing apply the spacing of their adjacent sections.
List {
Section("Colors") {
Text("Blue")
Text("Red")
}
Section("Borders") {
Text("Dashed")
Text("Solid")
}
.listSectionSpacing(10.0)
Section("Shapes") {
Text("Square")
Text("Circle")
}
.listSectionSpacing(100.0)
}In the above example, the "Colors" and "Borders" section are separated by 10 pts of spacing, and the "Borders" and "Shapes" section are separated by 55 pts of spacing.
Spacing applied on sections in the List overrides spacing applied on
the List as a whole.
See also
More in Lists and tables.
- deleteDisabledAdds a condition for whether the view's view hierarchy is deletable.
- listItemTintSets the tint effect for content in a list.
- listRowBackgroundPlaces a custom background view behind a list row item.
- listRowInsetsSets the insets of rows in a list on the specified edges.
- listRowSeparatorSets the display mode for the separator associated with this specific row.
- listRowSeparatorTintSets the tint color associated with a row.
- listRowSpacingSets the vertical spacing between two adjacent rows in a List.
- listSectionIndexVisibilityChanges the visibility of the list section index.
- listSectionMarginsSet the section margins for the specific edges.
- listSectionSeparatorSets whether to hide the separator associated with a list section.
- listSectionSeparatorTintSets the tint color associated with a section.
- moveDisabledAdds a condition for whether the view's view hierarchy is movable.