the answer by @Superdev right on the spot, what I want to add is a little trick if you want to grab the parent view and avoid subqueries (particularly the overlay view), what you can do is make this a subview property and use the following
CGFloat width = CGRectGetWidth(self.view.bounds); CGFloat height = CGRectGetHeight(self.view.bounds); _overlayView.hidden = YES; UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); CGRect rect = CGRectMake(0,0 ,width, height); CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], rect); UIImage *img = [UIImage imageWithCGImage:imageRef]; UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil); CGImageRelease(imageRef); _overlayView.hidden = NO;
his little trick, hope someone finds it useful
carelesslyChoosy
source share