Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Last active June 24, 2020 11:09
Show Gist options
  • Save prafullakumar/1511acd0fd4cbce28bf5929201fac2dd to your computer and use it in GitHub Desktop.
Save prafullakumar/1511acd0fd4cbce28bf5929201fac2dd to your computer and use it in GitHub Desktop.
struct ContentView: View {
let collums = [
/// define number of caullum here
GridItem(.flexible()),
GridItem(.flexible())
]
var body: some View {
ScrollView(.vertical) { //set .horizontal to scroll horizontally
LazyVGrid(columns: collums) { // use HGrid to layout horizontally
ForEach(0...50, id: \.self) { i in
Text("Grid: \(i)").frame(width: 100, height: 100, alignment: .center)
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment