SwiftUI: LazyVGrid, GridItem filling width

Viewed 198

I am trying to create a grid with a known number of columns. For this example the number of columns is 3.

I would like the first column to fill the space available, but it looks like it only fills 1/3 of the space available.


struct ContentView: View {
    var body: some View {
        LazyVGrid(columns: self.columns, alignment: .leading, spacing: 10) {
            Group {
            Text("Fill")
                .frame(maxWidth: .infinity)
            Text("Adapt")
            Text("Adapt")
            }
            .background(Color.red)
        }
    }
    
    var columns = [
        GridItem(.flexible()),
        GridItem(.flexible()),
        GridItem(.flexible())
        ]
}

Result: enter image description here

But I would like the first column to fill all the available space, while the last 2 columns are pushed to the right side.

Is this possible with a LazyVGrid?. Of course without having to specify frame sizes manually. Thanks!

0 Answers
Related