-
-
Save StanDimitroff/337838ba89e3226e5c68a119eca8103f to your computer and use it in GitHub Desktop.
SwiftUI @ViewBuilder example
This file contains 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
import SwiftUI | |
struct CustomVStack<Content: View>: View { | |
let content: () -> Content | |
init(@ViewBuilder content: @escaping () -> Content) { | |
self.content = content | |
} | |
var body: some View { | |
VStack(spacing: 0) { | |
content() | |
} | |
} | |
} | |
struct CustomVStack_Previews: PreviewProvider { | |
static var previews: some View { | |
CustomVStack { | |
Text("1") | |
Text("2") | |
Text("3") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment