У меня есть следующий код:
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". Если изображение не отображается, то нет отступов. Что вызывает отступы?