SwiftUI LazyGrid
Sat Oct 03 2020 16:28:11 GMT+0000 (UTC)
Saved by
@geoo993
import SwiftUI
struct ContentView: View {
let colors: [Color] = [.red, .green, .yellow, .blue]
var columns: [GridItem] =
Array(repeating: .init(.flexible(), alignment: .center), count: 3)
var body: some View {
ScrollView {
LazyVGrid(columns: columns, spacing: 10) {
ForEach(0...100, id: \.self) { index in
Text("Tab \(index)")
.frame(width: 110, height: 200)
.background(colors[index % colors.count])
.cornerRadius(8)
}
}
}
}
}
content_copyCOPY
https://medium.com/better-programming/whats-new-in-swiftui-2-0-ed13f2c40ae2
Comments