A UIImageVIew
(imageView
) is added to self.view
, capturing the view to album works perfectly:
CGSize size = CGSizeMake(self.view.frame.size.height, self.view.frame.size.width);
UIGraphicsBeginImageContext(size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
However, if the imageView
subview is rotated by:
[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
Capturing self.view
again does not reflected the rotation. The subview imageView
is as if not rotated.
How to make renderInContext
works with subviews rotated by CABasicAnimation
?
UPDATE:
Warning: The CALayer/-renderInContext: method doesn't implement the full Core Animation composition model. The code provided below will be able to resolve most of the situations, but there are things that the CALayer/-renderInContext: method doesn't render correctly, so you may wish to contact Developer Technical Support for workaround requests.
Official Apple Technical Q&A QA1703 suggested to contact Developer Technical Support for workaround requests.
Is there a workaround already existed?