SwiftUI tips and tricks
How to create a custom view that accepts optional content through ViewBuilder closures
ViewBuilder closures are one of the most important and widely used function builders in SwiftUI. They let you create a view out of a closure containing multiple child views.
For example, we might create a view called
RedPage which is a reusable full screen view with a red background, a…