The init is defined as:
init(
alignment: HorizontalAlignment = .center,
spacing: CGFloat? = nil,
@ViewBuilder content: () -> Content
)
So, you can also call
struct ContentView: View {
var body: some View {
VStack(content: {
Text("sth")
})
}
}
The Stack { } where the content (closure) is outside the parameters list, is just a writing facility.
You can do the same in other Swift functions:
array.map() { closure }
or
array.map { closure}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: