I am trying to create a List View where rows looks like this:
However, I am unable to align the Circle
on the leading side. Tried using Spacer()
, HStack
within VStack
, it just doesn't work. Here's my code and its output.
struct PeopleView: View {
let people = ["Adam", "James"]
var body: some View {
NavigationView {
List {
ForEach(people, id: .self) { person in
HStack {
Circle()
VStack {
Text("(person)")
}
}
}
}
.navigationBarTitle("People", displayMode: .inline)
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…