Save a view as image in original size

384 Views Asked by At

there are many threads about how to save a view as an image. And all of them give the same answer:

CGRect rect = [myView bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,[[UIScreen mainScreen] scale]);
CGContextRef context = UIGraphicsGetCurrentContext();
[myView.layer renderInContext:context];   
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

my problem is that I have a view that contains several joined imageViews that contain images. I want to save that "holder" view in a size that corresponds to the size of images residing inside it. So if i have 2 images 400x400 side by side, I'd like to save 400x800 image, regardless that they are displayed lets say 30x60.

Plus the above code only captures what's on the screen and leaves out the rest. For instance if i wanted to get the entire scrollview with its content size, it's not possible.

any ideas?

1

There are 1 best solutions below

4
On

If you want to get an image of the entire contentSize of a UIScrollView, take a look at this.