Skip to content

Instantly share code, notes, and snippets.

@Kievkao
Created October 6, 2020 06:37
Show Gist options
  • Select an option

  • Save Kievkao/e17423e20452b595a9fb25a0b7bc7262 to your computer and use it in GitHub Desktop.

Select an option

Save Kievkao/e17423e20452b595a9fb25a0b7bc7262 to your computer and use it in GitHub Desktop.
SwiftUI grid spans
struct ColSpan<Content: View>: View {
let span: Bool
let content: () -> Content
init(span: Bool, @ViewBuilder content: @escaping () -> Content) {
self.span = span
self.content = content
}
var body: some View {
content()
if span { Color.clear }
}
}
ForEach(0..<8) { idx in
ColSpan(span: idx == 4) {
Image("\(idx % 15)")
.resizable()
.frame(width: idx == 4 ? 310 : 150, height: 150)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment