Understand how to use ZStack, VStack, and HStack.

There are three built-in stacking views in SwiftUI; VStack, HStack, and ZStack. All three stacks are of type View. Stacks have alignment and content parameters. VStack & HStack also have a spacing parameter. In SwiftUI, the last parameters can be omitted, the default alignment in the center and the spacing is dynamic when it is not specified.

Instead of writing the code as below :

	import SwiftUI 

	struct ContentView: View {
	    var body: some View {
	      VStack (alignment: .center, spacing: 20, content: {
	          // UI elements 
	      }
	    )
	   }
	}

You can write it in a simplified way as below:

	import SwiftUI 

	struct ContentView: View {
	  var body: some View {
	    VStack {
	      // UI elements
	    }
	  }
	}

#ios-development #ios-programming #swiftui #swift #swift-programming

How To Stack Views & Use Modifiers Efficiently in SwiftUI
2.55 GEEK