Размещайте интервалы вокруг изображения, но не вокруг текста - PullRequest
1 голос
/ 10 января 2020

У меня есть следующий код:

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)
        }
    }
}

Результат выглядит следующим образом:

vertical stack showing two texts, an image and another text, with space around the image

Почему существует интервал вокруг изображение, а не вокруг текстов? Он исчезает, когда я явно устанавливаю интервал для VStack.

1 Ответ

2 голосов
/ 10 января 2020
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.

Последняя строка - "стек должен выбирать расстояние по умолчанию для каждой пары детей "

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...