将 SFSymbol 添加到 VStack 内的 HStack 时,我在 HStack 之后得到奇数间距。关于如何保持正常 VStack 间距的任何想法:
我添加了边框,所以你可以看到发生了什么
struct ContentView: View {
var body: some View {
VStack {
HStack {
Spacer()
Text( "This is text" )
Spacer()
}
.border( Color.orange, width: 1 )
Text("Hello, World!")
.border( Color.red, width: 1 )
Text("FooBar")
.border( Color.blue, width: 1 )
}
}
}
添加图像时:
struct ContentView: View {
var body: some View {
VStack {
HStack {
Spacer()
Text( "This is text" )
Spacer()
Image( systemName: "chevron.right" )
}
.border( Color.orange, width: 1 )
Text("Hello, World!")
.border( Color.red, width: 1 )
Text("FooBar")
.border( Color.blue, width: 1 )
}
}
}