Swiftui 将图像添加到HStack会影响间距

Swiftui 将图像添加到HStack会影响间距,swiftui,Swiftui,我有以下代码: import SwiftUI struct ContentView: View { var isShowingImage = true var body: some View { VStack(alignment: .leading) { HStack { Text("Lorem ipsum").fontWeight(.bold).lineLimit(1).border(Color.gree

我有以下代码:

import SwiftUI

struct ContentView: View {
    var isShowingImage = true
    var body: some View {
        VStack(alignment: .leading) {
            HStack {
                Text("Lorem ipsum").fontWeight(.bold).lineLimit(1).border(Color.green)
                if isShowingImage {
                    Image(systemName: "star.fill")
                    .resizable()
                    .frame(width: 16, height: 16).border(Color.blue)
                }
            }.border(Color.black)
            Text("Ad veritatis totam asperiores est error. Dolore perspiciatis unde aut.").lineLimit(1).border(Color.purple)
            Text("Dolorem illum").font(.footnote).border(Color.red)
        }.padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        HStack {
            ContentView()
            ContentView(isShowingImage: false)
        }
    }
}
这将产生以下结果:


如果
isShowingImage
为真,则显示图像。这也会在第一个
HStack
和文本“Ad veritatis”之间添加填充。如果没有显示图像,则没有填充。什么原因导致填充?

不确定是什么原因导致填充,但如果使用
VStack(对齐:。前导,间距:0)
则空格消失答案是,存在默认间距。如果将堆栈间距保留为零,则堆栈将选择默认间距。

是的,我自己发现了这一点,但我不是在寻找解决方法,而是寻找原因。谢谢你的回复。