I am trying to alight my text Final Context below Hello World and after Text1 but I am unable to do so, here is my code. I am new to SwiftUI.
VStack {
HStack{
Text("Text1")
Toggle(isOn: binding){
Text("Hello World")
}.padding()
}
Text("Final Context")
}
}
4
Answers
Try adding
alignment: .leading
to theVStack
:You have to align your vStack to leading. Your code should look like this:
import SwiftUI
Then you get the alignment, like this:
What about this:
Use a
VStack
insideHStack
.