Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created August 29, 2022 21:14
Show Gist options
  • Select an option

  • Save sturdysturge/e3024f0fe22de63b781650127f16910e to your computer and use it in GitHub Desktop.

Select an option

Save sturdysturge/e3024f0fe22de63b781650127f16910e to your computer and use it in GitHub Desktop.
import SwiftUI
@available(iOS 16.0, *)
struct ContentView {
@State var alignment: HorizontalAlignment = .center
var grid: some View {
Grid {
GridRow {
Text("Aligned")
.gridColumnAlignment(alignment)
ForEach(1...2, id: \.self) { index in
Text("Cell A\(index)")
.padding()
.border(Color(red: 1 / Double(index), green: 0, blue: 0), width: 3)
}
}
GridRow {
ForEach(1...3, id: \.self) { index in
Text("Cell B\(index)")
.padding()
.border(Color(red: 0, green: 1 / Double(index), blue: 0), width: 3)
}
Rectangle()
.frame(width: 2, height: 15)
.gridColumnAlignment(alignment)
}
GridRow {
ForEach(1...4, id: \.self) { index in
Text("Cell C\(index)")
.padding()
.border(Color(red: 0, green: 0, blue: 1 / Double(index)), width: 3)
}
}
}
.frame(maxWidth: .infinity)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment