I have a UIView, setup on a superview using auto-layout and its subviews are setup too through auto-layout. I want to be able to resize the view to capture its resized contents to a UIImage, while keeping the view displayed on screen the same size.
I know I can use:
UIGraphicsBeginImageContextWithOptions(myView.bounds.size, NO, 0.0);
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImg = UIGraphicsGetImageFromCurrentImageContext();
to obtain the image from the view,
but how do I resize the view JUST for capturing its contents, whilst leaving it untouched on display?
Thanks
EDIT for clarity
I want to be able to increase the width of the view, changing the aspect ratio of the view, allowing for the auto layout constraints to arrange its subviews to its new size.
Is it possible to simply copy the view, don't add it as a subview of the main window (so it's not visible) and change its frame, then capture it?