How to build container view in SwiftUI
Issue #780
To make a container view that accepts child content, we use ViewBuilder
1 | struct ContainerView<Content: View>: View { |
From Swift 5.4, it can synthesize the init
, so we can declare resultBuilder
for stored property
struct AwesomeContainerView<Content: View>: View {
@ViewBuilder
let content: Content
var body: some View {
content
}
}
Updated at 2021-02-24 21:22:49