-1

I have a UIView that has another UIView and a UIImageView inside of it. I want to flaten the UIImage onto the UIView. If it helps you can think of the layout like this:
-UIView
---UIImageView
---UIView

How can I capture the whole UIView and save it as a single image?

rmaddy
  • 307,833
  • 40
  • 508
  • 550
Tyler Hilbert
  • 1,987
  • 7
  • 32
  • 52

1 Answers1

1

You can use this to save your views as a single image.

-(UIImage *)visibleImage
{
    UIGraphicsBeginImageContextWithOptions(yourview.frame.size, YES, [UIScreen mainScreen].scale);
    CGContextTranslateCTM(UIGraphicsGetCurrentContext(), CGRectGetMinX(yourview.frame) , CGRectGetMinY(yourview.frame));

    [yourview.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *img_FinalVisible  = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return img_FinalVisible;
}
Sven Schoenung
  • 29,194
  • 8
  • 60
  • 66