πŸ”ͺ
Cutting-Edge SwiftUI Apps
  • πŸ“³Cutting-Edge SwiftUI Apps
  • TUTORIALS AND TIPS
    • πŸ‘‹Introduction
  • ▢️Start with Charts
    • πŸ‘©β€πŸ’»Necessary Installations
    • Bar Mark
      • Chart Data driven
      • Xcode
    • Design as a time series
      • Bar graph
      • More data
      • Multi-series Line chart
  • ▢️New Window
    • πŸ‘©β€πŸ’»Necessary Installations
    • Single Unique Window
    • Menu bar
  • ▢️New Sharing
    • πŸ‘©β€πŸ’»Necessary Installations
    • ShareLink API
  • ▢️Start with Layout
    • Grid
  • WRAPPING IT UP
  • πŸ€Έβ€β™€οΈAuthor
  • πŸ“–References
Powered by GitBook
On this page
  1. Start with Layout

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()
            }
        }
    }
}

PreviousStart with LayoutNextAuthor

Last updated 2 years ago

▢️