Created
October 6, 2020 06:37
-
-
Save Kievkao/e17423e20452b595a9fb25a0b7bc7262 to your computer and use it in GitHub Desktop.
SwiftUI grid spans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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