I know that this code renders a UIView into a UIImage:
- (UIImage *)captureView {
//hide controls if needed
CGRect rect = [self.view bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
However, how to take a snapshot of a view that has multiple UIViews on top of it but only some of these UIViews? For instance, imagine Snapchat. You take a picture, and then you can add emojis, text, and paint as much as you want. Each one of these are separate UIViews. However, when we click on the button to post a snap, Snapchat include everything on the final image except the UI buttons ( like open-emoji-menu button, post button, save to gallery button, write-text button, etc..). It's like as if these UIButtons were hidden on the time the snapshot was taken, but they are not hidden really. So how to achieve this? I believe they don't generate multiple images from every uiview, but rather take a single snapshot (screenshot) but exclude the UIButton from going into the final image. Any ideas anyone, please?