Grid

Grid is a new container view that arranges views in a two-dimensional grid.

Grid will measure its subviews up front to enable cells that span multiple columns and enable automatic alignments across rows and columns.

This particular grid view contains two GridRow instances. Within a row, each view corresponds to a column.

πŸ”₯ In contentView add a second tab

// Create a Grid View

import Charts

import SwiftUI

struct ContentView: View {

@State private var selection = 2

var body: some View {

TabView(selection: $selection) {

WinesTab()

.tabItem {

Label("Wines", systemImage: "chart.bar.doc.horizontal")

}

.tag(1)

Grid {

GridRow {

ParisDetailsChart()

.gridCellColumns(2)

}

GridRow {

AmsterdamDetailsChart()

SalesDetailsChart()

}

}

.tabItem {

Label("Overview", systemImage: "square.grid.2x2")

}

.tag(2)

}

}

}

struct ContentView_Previews: PreviewProvider {

static var previews: some View {

ContentView()

}

}

// Example

struct WeatherDetailView: View {
    var body: some View {
        Grid {
            GridRow {
                NameHeadLine()
                    .gridCellColumns(2)
            }
            GridRow {
                CalendarIcon()
                SymbolGrid()
            }
        }
    }
}

Last updated