0

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).

Mehdi
  • 888
  • 5
  • 16
arsalan_h
  • 43
  • 3
  • 1
    Welcome to StackOverflow. Please show what research you've undertaken, what you've already tried, what didn't work, code samples etc. Read [ask] and [mcve] and update your question. – Ashley Mills Oct 01 '19 at 12:37

1 Answers1

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
  • 888
  • 5
  • 16
  • 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