-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
  • 314,917
  • 42
  • 532
  • 579
Tyler Hilbert
  • 2,107
  • 7
  • 35
  • 55

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
  • 30,224
  • 8
  • 65
  • 70