Last active
March 6, 2021 05:18
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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