Skip to content

Instantly share code, notes, and snippets.

@StanDimitroff
Forked from rboyce/CustomVStack.swift
Created December 10, 2019 14:05
Show Gist options
  • Save StanDimitroff/337838ba89e3226e5c68a119eca8103f to your computer and use it in GitHub Desktop.
Save StanDimitroff/337838ba89e3226e5c68a119eca8103f 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