给出以下GeometryReader(...)
:
GeometryReader { geo in
Path { path in
let width = geo.size.width
let height = geo.size.height * 0.40
let litheight = geo.size.height * 0.24
path.addLines([
CGPoint(x: 0, y: litheight),
CGPoint(x: width, y: height ),
CGPoint(x: width, y: 0),
CGPoint(x: 0, y: 0)
])
}
}.edgesIgnoringSafeArea(.top)
我想用背景图像设置顶部区域。
除了不完全符合我的要求,我尝试了以下操作:
GeometryReader { geo in
Path { path in
let width = geo.size.width
let height = geo.size.height * 0.40
let litheight = geo.size.height * 0.24
path.addLines([
CGPoint(x: 0, y: litheight),
CGPoint(x: width, y: height ),
CGPoint(x: width, y: 0),
CGPoint(x: 0, y: 0)
])
}
Image(systemName: "faceid")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: geo.size.width, height: geo.size.height, alignment: .bottomTrailing)
}
.edgesIgnoringSafeArea(.top)
这是结果:
这就是我想要实现的: