I want to create a VStack of many Texts with 20 points of spacing between each Text. I want my VStack to be aligned to left side of the screen(or leading side of parent View).
Asked
Active
Viewed 1,950 times
2 Answers
5
Try this:
struct ContentView: View {
var body: some View {
HStack(){
//alignment options: .center , .leading , .trailing
VStack(alignment: .leading, spacing: 20){
Text("Salam")
Text("chetori")
Text("Arsalan")
Text("?")
}
Spacer()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
and if you want your VStack to be on right side of your screen, put the Spacer above the VStack

Mehdi
- 1,192
- 1
- 9
- 21
-
salam,khubam mersi =) this aligment: .leading is just inside VStack and still show this texts on center of the view ,i want padding this whole VStack to the left of the view – arsalan_h Oct 02 '19 at 10:53