Created
June 9, 2019 05:26
-
-
Save rboyce/7a80bdc402823b485601abb9939b03c3 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