listSectionSeparatorTint

Sets the tint color associated with a section.

View ModifieriOS 15.0+macOS 13.0+listSectionSeparatorTint(_:edges:) in SwiftUI

Declaration

React
compose().listSectionSeparatorTint(
  color: SwiftUI.Color | null,
  options?: {
    edges?: SwiftUI.VerticalEdgeSet;
  }
)
Swift
nonisolated func listSectionSeparatorTint(
    _ color: Color?,
    edges: VerticalEdge.Set = .all
) -> some View

Parameters

  • color*SwiftUI.Color | null

    The color to use to tint the section separators, or nil to use the default color for the current list style.

  • The set of row edges for which the tint applies. The list style might decide to not display certain separators, typically the top edge. The default is VerticalEdge.Set.all.

Discussion

Separators can be presented above and below a section. You can specify to which edge this preference should apply.

This modifier expresses a preference to the containing List. The list style is the final arbiter for the separator tint.

The following example shows a simple grouped list whose section separators are tinted based on section-specific data:

List {
    ForEach(garage) { garage in
        Section(header: Text(garage.location)) {
            ForEach(garage.cars) { car in
                Text(car.model)
                    .listRowSeparatorTint(car.brandColor)
            }
        }
        .listSectionSeparatorTint(
            garage.cars.last?.brandColor, edges: .bottom)
    }
}
.listStyle(.grouped)

To change the visibility and tint color for a row separator, use View.listRowSeparator(_:edges:) and View.listRowSeparatorTint(_:edges:). To hide a section separator, use View.listSectionSeparator(_:edges:).

See also

More in Lists and tables.