I am hoping to be able to 'crop' a SwiftUI Image() and have the resulting (cropped) Image fill the space previously occupied by the Image() (aspectRatio differences not withstanding)
In the code below, commenting out the .clipShape
modifier displays the original image, spanning the full width available.
When I add the .clipShape
modifier, the resulting image only occupies its small portion of the original image. I want to stretch it to fill the available space, but don't know how I might do this.
Any/all guidance appreciate
struct ContentView: View {
var body: some View {
VStack() {
Image("Hana")
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(CropFrame())
}
}
}
struct CropFrame: Shape {
func path(in rect: CGRect) -> Path {
return Path(CGRect(x: 17, y: 5, width: 73, height: 80))
}
}
My preference would have been to operate on a UIImage, however based on limitations outside the scope of this question, my most viable option is to operate on the SwiftUI Image()
thx again :-)