0

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".

enter image description here

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)
            }
        }
    }
}
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
user14119170
  • 1,191
  • 3
  • 8
  • 21

0 Answers0