我目前正在做一个小项目,我真的不知道如何解决一些问题,问题是我不知道如何在不同的站点上对齐水平堆栈中的两个项目。以下是当前状态的屏幕截图:
当前状态
这就是它应该是什么样子:
它应该看起来像
这是当前的代码:
var body: some View {
Button {
}
label: {
HStack{
VStack(alignment: .leading) {
Text("Max Mustermann")
Text("Mustermann GmbH")
.fontWeight(.thin)
}
Image(systemName: "arrow.forward.circle")
}
.frame(minWidth: 320, minHeight: 50, alignment: .leading)
.foregroundColor(.black)
.padding()
.overlay(
RoundedRectangle(cornerRadius: 15)
.stroke(.gray, lineWidth: 1))
}
}
}
我希望有人能帮我:(非常感谢。
似乎需要一个间隔符:(只需将其添加到HStack中的视图之间,如下所示:
HStack{
VStack(alignment: .leading) {
Text("Max Mustermann")
Text("Mustermann GmbH")
.fontWeight(.thin)
}
Spacer() // The New Spacer Here
Image(systemName: "arrow.forward.circle")
}
上面链接的文档很好地说明了使用间隔符可以实现什么:(
祝你好运!