Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created June 23, 2020 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/f0f5cab346851829c3f01f3e02d309be to your computer and use it in GitHub Desktop.
Save stevencurtis/f0f5cab346851829c3f01f3e02d309be to your computer and use it in GitHub Desktop.
lvgcode
import SwiftUI
struct LazyVGridExampleView: View {
let colors: [Color] = [.red, .blue, .green]
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("Cell \(index)")
.frame(width: 110, height: 200)
.background(colors[index % colors.count])
.cornerRadius(10)
}
}
}
}
}
struct LazyVGridExampleView_Previews: PreviewProvider {
static var previews: some View {
LazyVGridExampleView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment