My Profile Photo

Hao's Keeper


A blog to place memos


Insert Empty View in Grid

SwiftUI Grid

Grid {
	GridRow {
		ColorSquare(color: .pink)
		Color.clear
			.gridCellUnsizedAxes([.horizontal, .vertical])
		ColorSquare(color: .pink)
	}
	GridRow {
		ForEach(0..<3) { _ in
			ColorSquare(color: .green)
		}
	}
}

Results:

Pink   Pink
Green Green Green

gridCellUnsizedAxes: Asks grid layouts not to offer the view extra size in the specified axes.