Skip to content

Instantly share code, notes, and snippets.

@rboyce
Created June 9, 2019 05:26
Show Gist options
  • Save rboyce/7a80bdc402823b485601abb9939b03c3 to your computer and use it in GitHub Desktop.
Save rboyce/7a80bdc402823b485601abb9939b03c3 to your computer and use it in GitHub Desktop.
SwiftUI @ViewBuilder example
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