Quote:
Originally Posted by sacha1996
|
This is what I am trying:
UIGraphicsBeginImageContext(self.view.frame.size);
CGContextRef theContext = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:theContext];
CGRect overDrawRects[] = {CGRectMake(10, 0, 1, Picture_ImageView.frame.size.height), CGRectMake(Picture_ImageView.frame.size.width - 11, 0, 1, Picture_ImageView.frame.size.height)};
[[UIColor clearColor] set];
for (int i = 0; i < 2; i++) {
UIRectFill(overDrawRects[i]);
CGContextSaveGState(theContext);
CGContextClipToRect(theContext, overDrawRects[i]);
CGContextTranslateCTM(theContext, -1, 0);
[Picture_ImageView.layer renderInContext:theContext];
CGContextRestoreGState(theContext);
}
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(theImage, nil, nil, nil);
It saves the entire screen. It does save the layers on top of my image view but I only want to take a screenshot of the screen where my image view is located. I have tried switching out self.view for Picture_ImageView and all kinds of variations of that with no success.