Skip to content

Instantly share code, notes, and snippets.

@IntegerOverlord
Created December 19, 2023 10:07
Show Gist options
  • Save IntegerOverlord/3bba7f39e884f0e8b5fe53a121af35d5 to your computer and use it in GitHub Desktop.
Save IntegerOverlord/3bba7f39e884f0e8b5fe53a121af35d5 to your computer and use it in GitHub Desktop.
struct ContentView: View {
let data = (1...10000).map { "Item \($0)" }
let columns = [
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible())
]
var body: some View {
ScrollView {
LazyVGrid(columns: columns, spacing: 20) {
ForEach(data, id: \.self) { item in
ViewThatFits {
ZStack {
Rectangle()
.foregroundStyle(.blue)
Text(item)
.foregroundStyle(.white)
}
EmptyView()
}
}
}
.padding(.horizontal)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment