Every application has content, and that content is organised in the form of stacks and layouts. In SwiftUI, there are three major kinds of stacks, namely: VStack, HStack and ZStack. In this set of blogposts, I shall discuss these stacks.
VSTACK:
So, what is a VStack? Well, a VStack or Vertical Stack is used for putting things on top of each other. For example:
We can see a few rectangle on top of each other; this is a VStack. We would code it as such:
struct Stacks: View {
var body: some View {
NavigationView{
VStack(alignment: .center){
Rectangle()
.frame(width: 400, height: 120)
.foregroundColor(.gray)
.cornerRadius(14)
Text("Hello World")
.font(.system(size: 30, weight: .bold))
Rectangle()
.frame(width: 300, height: 300)
.foregroundColor(.secondary)
.cornerRadius(14)
Rectangle()
.frame(width: 300, height: 100)
.foregroundColor(.secondary)
.cornerRadius(14)
} .padding()
} .redacted(reason: .placeholder)
}
}