【发布时间】:2020-07-17 06:37:54
【问题描述】:
尝试将图像设置为我在 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()
}
}
}
输出
【问题讨论】: