swiftui - space around top of the background image
问题描述
Trying to set an image as a background for my view in SwiftUI. Using Xcode 12 beta and 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()
}
}
}
Output
解决方案
The following should be enough (tested with Xcode 11.4 / iOS 13.4)
var body: some View {
ZStack {
Image("background")
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
}
}
推荐阅读
- javascript - 数据表上的 django datepicker
- mysql - 如何从 Mysql 8.0 转储到 5.7?
- flutter - 如何在 Flutter 中创建圆角矩形
- javascript - 我为 Freecodecamp 创建了一个“收银机”功能,但由于某种原因,最后两个测试没有通过?
- python-3.x - 比较数据框中字典的两列,并添加列中不存在的键值对
- gulp - 将 gulp 从 3 升级到 4 - 必须指定任务功能错误 - 怎么办?
- reactjs - 如何查找用户何时停止输入受控组件?
- python - 如何从 FormRequest 对象中获取回调函数结果
- c# - 我想下载 DriveItem 的内容,如何获取 driveItem 的 ID?
- forms - 通过谷歌表中的列动态更新选项列表的解决方案