So, I want a List in SwiftUI, where the border of each row depends on some function of the contents of the row. Normally I can do this easily with .border()
but List seems to take care of the styling for the elements itself, adding padding and that.
The closest I have is below, which is quite far from what I'm after. This produces the borders around the text fields, but I want instead to produce borders around the whole cell.
struct ListDemoView: View { @State private var nums: [Int] = [1, 2, 3, 4, 5] var body: some View { List (nums, id: \.self) { num in Section { Text("Num: \(num)") } .border(num % 2 == 0 ? Color.red : Color.blue) } }}