Hello experts!
My situation is like this, I want to programmatically take a print screen of the current view visible to the user and save this to the photo album. The problem is that I don't want all of the views in the hierarchy to be visible. My plan was to:
- Make a copy of the view hierarchy.
- Hide the subviews which were not interesting.
- Take the print screen.
- Save it to the photo album.
The problem is that I'm stuck on the first point. Since UIView
does not implement the NSCopying
protocol I can't make a deep copy of the view hierarchy. I tried archiving and unarchiving the views but this was only available on the dektop.
As I see it there there are two options here:
a) Implement the NSCopying protocol on all the views and subviews.
b) Fade a white view covering the whole screen (sort of like the flash-effect when you take a print screen manually) and in that instant I hide the views I want.
Is there some other way of approaching this problem that I have missed?
Edit:
UIGraphicsBeginImageContext([[wordManager mainWorkViewController] view].frame.size);
[[[[wordManager mainWorkViewController] view] layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Best regards //Abeansits