图像周围的 VStack 间距,而不是文本周围的间距

问题描述:

我有以下代码:

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            Text("ContentView Header 1")
                .border(Color.green, width: 2)
            Text("ContentView Header 2")
                .border(Color.green, width: 2)
            Image(systemName: "arrow.up")
                .border(Color.green, width: 2)
            Text("ContentView Footer 1")
                .border(Color.green, width: 2)
        }
    }
}

结果如下:

为什么图像周围有间距,而文本周围没有?当我为 VStack 显式设置间距时,它就会消失.

Why is there spacing around the image, but not around the texts? It disappears when I explicitly set spacing for the VStack.

public struct VStack<Content> : View where Content : View {

    /// Creates an instance with the given `spacing` and Y axis `alignment`.
    ///
    /// - Parameters:
    ///     - alignment: the guide that will have the same horizontal screen
    ///       coordinate for all children.
    ///     - spacing: the distance between adjacent children, or nil if the
    ///       stack should choose a default distance for each pair of children.

最后一行 - 堆栈应该为每对孩子选择默认距离"

Last line - "stack should choose a default distance for each pair of children"