Created
June 23, 2020 16:58
-
-
Save stevencurtis/f0f5cab346851829c3f01f3e02d309be to your computer and use it in GitHub Desktop.
lvgcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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