Overloads
2 ways to call compose().listRowInsets(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().listRowInsets(
edges: SwiftUI.EdgeSet | undefined,
length: number | null
)nonisolated func listRowInsets(
_ edges: Edge.Set = .all,
_ length: CGFloat?
) -> some ViewParameters
edges*SwiftUI.EdgeSet | undefinedThe edges to set the insets to.
length*number | nullAn amount, given in points, to set the insets to on the specified edges.
Return value
A view in which the margins of list sections are set to the specified amount
Discussion
Use this modifier to change the default insets of list rows on the specified edges.
In the example below, the Flavor enumeration provides content for list
items. The SwiftUI ForEach structure computes views for each element
of the Flavor enumeration and extracts the raw value of each of its
elements using the resulting text to create each list row item. The
listRowInsets(_:_:) modifier then changes the leading inset of each
row of the list and leaves the default insets on the other edges
untouched:
struct ContentView: View {
enum Flavor: String, CaseIterable, Identifiable {
var id: String { self.rawValue }
case vanilla, chocolate, strawberry
}
var body: some View {
List {
ForEach(Flavor.allCases) {
Text($0.rawValue)
.listRowInsets(.leading, 25)
}
}
}
}When applying multiple listRowInsets modifiers, modifiers with the
same edges will override modifiers higher up in the view hierarchy.
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.
- 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.
- listSectionSpacingSets the spacing between adjacent sections in a List to a custom value.
- moveDisabledAdds a condition for whether the view's view hierarchy is movable.