ios - 在制作动画时捕获屏幕
<p><p>我需要在动画制作时捕捉 View 。以下代码我用来在动画时捕获图像。</p>
<pre><code>myTimer = ;
[ addTimer:myTimer forMode:NSRunLoopCommonModes];
UIImage * toImage = [objectAtIndex:1];
[UIView transitionWithView:beforeImgView
duration:5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
beforeImgView.image = toImage;
}
completion:^(BOOL finished) {
;
}];
}
-(void)captureImage:(NSTimer*) t {
CALayer *layer;
layer = ;
UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextClipToRect (UIGraphicsGetCurrentContext(),self.view.frame);
;
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}
</code></pre>
<p>它只捕获结果图像</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您可以使用具有动画对象的 View 副本,并使用该副本 View 来捕获屏幕。即</p>
<pre><code>UIView *copyView = ;
CALayer *layer;
layer = ;
UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextClipToRect (UIGraphicsGetCurrentContext(),copyView.frame);
;
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
</code></pre></p>
<p style="font-size: 20px;">关于ios - 在制作动画时捕获屏幕,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/20489520/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/20489520/
</a>
</p>
页:
[1]