space 背景图片顶部附近

space around top of the background image

正在尝试将图像设置为我在 SwiftUI 中的视图的背景。使用 Xcode 12 测试版和 iOS 14.

struct ContentView: View {
var body: some View {
    ZStack {
        Image("background")
            .resizable()
            .scaledToFill()
            .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height, alignment: .center)
            .clipped()
    }
}

}

输出

以下应该足够了(用Xcode 11.4 / iOS 13.4测试)

var body: some View {
    ZStack {
        Image("background")
            .resizable()
            .scaledToFill()
            .edgesIgnoringSafeArea(.all)
    }
}