Skip to content

Instantly share code, notes, and snippets.

@pitt500
Last active March 6, 2021 05:18
Show Gist options
  • Save pitt500/965aa17728930c49568d4c1e2e922df8 to your computer and use it in GitHub Desktop.
Save pitt500/965aa17728930c49568d4c1e2e922df8 to your computer and use it in GitHub Desktop.
Method to hide default separator lines in a SwiftUI's List. You need to call it in the cell (as a modifier), not the list.
// Call this in the cell, for example CellView().noSeparators()
extension View {
@ViewBuilder public func noSeparators(
edgeInsets: EdgeInsets = EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0),
color: Color
) -> some View {
self
.padding(edgeInsets)
.frame(
minWidth: 0,
maxWidth: .infinity,
minHeight: 44,
alignment: .leading
)
.listRowInsets(EdgeInsets())
.background(color)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment