Reputation:
How I could have a line on top of every columns in this lazyVGrid?
LazyVGrid(columns: Array(repeating: GridItem(spacing: .zero), count: 7), spacing: .zero) {
ForEach(0..<36) { i in
Text("\(i)")
}
}
Upvotes: 2
Views: 1611
Reputation: 1
Here is a way for you:
struct ContentView: View {
private let range: ClosedRange<Int> = 0...35
var body: some View {
LazyVGrid(columns: Array(repeating: GridItem(spacing: .zero), count: 7), spacing: .zero) {
ForEach(range, id: \.self) { index in
VStack(spacing: .zero) {
Text(String(describing: index))
if (index < range.upperBound) { Color.primary.frame(height: 2.0) }
}
}
}
.padding()
}
}
Upvotes: 3