If you want to place multiple elements vertically or horizontally, you can use VStack
and HStack
respectively.
Let's see how to place multiple texts vertically:
VStack {
Text("Text 1")
Text("Text 2")
Text("Text 3")
}
Or horizontaly:
HStack {
Text("Text 1")
Text("Text 2")
Text("Text 3")
}
Aligning and spacing the content
These two components can take up to two parameters, alignment
and spacing
. Both components have different alignments.
- VStack: leading, center, trailing
- HStack: top, center, bottom
.leading
and .trailing
are used instead of left and right in order to represent Right-To-Left (RTL) writting systems like Arabic or Hebrew. For these languages, .leading
will mean right, instead of left.
Be the first to comment