One of many things that make SwiftUI great is the ability to combine views. The template code when you create a new SwiftUI view contains the following:
struct ContentView: View {
var body: some View {
Text("Place Holder")
}
}
The body variable is expecting some View. In the example above we are returning a Text view which contains a string “Place Holder”. If you preview this in the canvas you will see the words “Place Holder”, without quotes, in the centre of the view.
Swift provides the ability to combine views so that more views can be combined in to one and then returned. In our Stacks tutorial we explain this. In short, you can combine views in to a HStack, VStack, or ZStack and return the stack as one view.
[Read more…]