This was a great tutorial. I've been looking for a while for something like this because the HWS code doesn't work in my case. However, using the Representable method you outlined here, the screenshot is taking the whole screen and including a view I don't want in the screenshot. I've tried moving the views around in their own ZStacks but still it shows up. Any thoughts are appreciated.
Hi, in my example I was able to screenshot a part of the screen, if you see I have one screenshot without the title and one with it. If you can share a code sample maybe I can help
And by the way, at WWDC they introduced a new way to take screenshot of Views, is called ImageRenderer so if you can target iOS 16 you don't need my workaround anymore
I tried putting the closure in multiple different ways but it always shows the whole screen and not just the view I want captured. Here is some code from my project.
(I did see that iOS 16 has some new share screen features but im targeting iOS 14+)
structContentView:View{//... some environmentObjectsvarbody:someView{ZStack{canvas.snapshotView{snapinsnapshotMaker=snap}pallet}}varcanvas:someView{Canvas()}}structCanvas:View{//... some environmentObjectsvarbody:someView{Rectangle().overlay(// Place current images on the canvasForEach(images){$0})}}
I've tried putting the canvas and pallet in their own ZStacks.
I want a snapshot of just the canvas without the pallet.
Thanks for your help. Hope your having fun at WWDC.
oh I see, I've tried with a ZStack and it takes a screenshot of everything. Basically what you see on screen is what you see on the png, while you want a screenshot of a partial content of the ZStack.
I will try to see if there is a solution to that
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This was a great tutorial. I've been looking for a while for something like this because the HWS code doesn't work in my case. However, using the Representable method you outlined here, the screenshot is taking the whole screen and including a view I don't want in the screenshot. I've tried moving the views around in their own ZStacks but still it shows up. Any thoughts are appreciated.
Hi, in my example I was able to screenshot a part of the screen, if you see I have one screenshot without the title and one with it. If you can share a code sample maybe I can help
And by the way, at WWDC they introduced a new way to take screenshot of Views, is called ImageRenderer so if you can target iOS 16 you don't need my workaround anymore
I tried putting the closure in multiple different ways but it always shows the whole screen and not just the view I want captured. Here is some code from my project.
(I did see that iOS 16 has some new share screen features but im targeting iOS 14+)
I've tried putting the canvas and pallet in their own ZStacks.
I want a snapshot of just the canvas without the pallet.
Thanks for your help. Hope your having fun at WWDC.
oh I see, I've tried with a ZStack and it takes a screenshot of everything. Basically what you see on screen is what you see on the png, while you want a screenshot of a partial content of the ZStack.
I will try to see if there is a solution to that