Why does my SwiftUI Grid not adapt to the space available? And how can I fix it?
I tried to follow and modify the code from Apple's WWDC video "Stacks, Grids, and Outlines in SwiftUI".
import SwiftUI
struct ContentView: View {
var body: some View {
albumGrid
}
}
let columns = [
// GridItem(.adaptive(minimum: 100))
GridItem(spacing: 0),
GridItem(spacing: 0),
GridItem(spacing: 0)
]
var albumGrid: some View {
ScrollView {
LazyVGrid(columns: columns, spacing: 0.2) {
ForEach(albums) { album in
Image(album.coverImageName)
}
}
}
}