Skip to content

Instantly share code, notes, and snippets.

@takoikatakotako
Created October 24, 2024 01:11
Show Gist options
  • Select an option

  • Save takoikatakotako/3f2fd638eed4f1e2b4c097c95b639066 to your computer and use it in GitHub Desktop.

Select an option

Save takoikatakotako/3f2fd638eed4f1e2b4c097c95b639066 to your computer and use it in GitHub Desktop.
SwiftUIでUICollectionViewのようにViewを並べる
import SwiftUI
struct ContentView: View {
let columns = [GridItem(.fixed(80)), GridItem(.fixed(80)), GridItem(.fixed(80)), GridItem(.fixed(80))]
var body: some View {
ScrollView {
LazyVGrid(columns: columns) {
ForEach(0..<100, id: \.self) { number in
Text("\(number)")
.foregroundStyle(Color.white)
.font(.title)
.frame(width: 80, height: 80)
.background(Color.gray)
}
}
}
}
}
#Preview {
ContentView()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment