// 裁剪一半
Image("")
.clipShape(CustomTopHalfClipShape())
struct CustomTopHalfClipShape: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
let height = rect.size.height
path.move(to: .zero)
path.addLine(to: CGPoint(x: rect.size.width, y: 0))
path.addLine(to: CGPoint(x: rect.size.width, y: height / 2))
path.addLine(to: CGPoint(x: 0, y: height / 2))
path.closeSubpath()
return path
}
}
swiftUI 裁剪图片
最新推荐文章于 2024-11-08 17:19:00 发布