I am trying to display a row inside my ListView in SwiftUI for MacOS.
However, my issue is that the row contains padding around it. I would like to stretch it to the boundaries of my ListView
.
Apple uses .listRowInsets(EdgeInsets())
in their example. However, that is only shown on iOS. For me, it is not working on macOS.
My row got a red border to visualize the issue. I want it to be stretched all the way to the boundaries of the List Row, so fill the whole blue row. Is that possible in macOS?
Thanks in advance.
For now I've found only workaround (.listRowInsets
should really do this work, so worth submitting feedback to Apple):
struct TestListRow: View {
var body: some View {
List {
ForEach (0..<3) { i in
HStack {
Text("Test row \(i)").font(.largeTitle)
Spacer()
}
}
.listRowBackground(Color.green)
.border(Color.red)
.padding(.horizontal, -8) // << workaround !!
}.environment(\.defaultMinListRowHeight, 40)
.border(Color.yellow)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With