1

I have some issues with taking a snapshot of a zoomable, scrollable image view.

I have a "testView":

var testView: some View {
    ZoomableScrollView {
        Image(uiImage: image!)
            .resizable()
            .scaledToFit()
            .clipped()
    }.frame(width: UIScreen.screenWidth * 0.9, height: UIScreen.screenHeight * 0.4)
}

and in this view, on button tapped, I would like to take a screenshot of testView (only what is visible)

            VStack {
                testView
                    .cornerRadius(12)
                
                Button(action: {
                    convertViewToData(view: testView, size: CGSize(width: gr.size.width, height: gr.size.), completion: {
                        convertedImage = UIImage(data: $0!)
                        DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                            showIdentityView()
                        }
                    })
                }) {
                    ButtonYellow(title: "Identify")
                        .offset(y: 10)
                }
            }

Image conversion is followed by this StackOverflow answer: https://stackoverflow.com/a/64358617/12689108

But instead of zoomed, edited view, I still get hole same image as it was never edited.

Also tried with GeometryReader { gr in } tried to give just width and height, still no luck.

Can anyone help with this?

The editing view is here(and what I expect to get as well):

enter image description here

After snapshotting I get this:

enter image description here

So what I want is, that the image that I used, edited would be

Jkrist
  • 748
  • 1
  • 6
  • 24

0 Answers0