【发布时间】:2013-01-01 01:44:45
【问题描述】:
我按照here 的说明在动画期间捕获屏幕截图(我正在尝试使用动画标签录制 UIView 以将其捕获为视频)
这是我在 ViewController (getframe) 中截屏的代码
-(UIImage*) getCurrentFrame {
UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextRef mycontext = UIGraphicsGetCurrentContext();
[[[self.view layer] presentationLayer] renderInContext:mycontext];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
当我尝试制作屏幕截图的视频时,我反复看到的只是开始帧 - 因为我的线程(使用 AVAssetwriter 示例)抓取后续屏幕截图,屏幕抓取移动中没有任何内容。在 AVAssetWriterInput 期间,在 while 循环中使用块调用 screengrab。
我的动画是标签上的简单核心动画 - 向下滚动示例
mTextLabel.frame = CGRectMake(mTextLabel.frame.origin.x,
-100,
mTextLabel.frame.size.width,
mTextLabel.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: delay];
[UIView setAnimationTransition:UIViewAnimationTransitionNone
forView:mTextLabel cache:YES];
mTextLabel.frame = CGRectMake(mTextLabel.frame.origin.x,
240,
mTextLabel.frame.size.width,
mTextLabel.frame.size.height);
[UIView commitAnimations];
我尝试用块动画 animatewithDuration 替换旧学校动画,但得到相同的结果
有什么建议吗? 使用 ios 6 和最新的 xcode(已正确导入 Quartzcore)
Apple 开发中心 said 可能无法捕获某些内容。
是否可以使用计时器和间歇性抓取屏幕来制作动画(必须手动编码动画)?
【问题讨论】:
-
我将放弃这一点 - 并使用服务器端解决方案 - 应用程序的项目/目标设置中有一个选项允许 OpenGl 捕获,但我不知道这是否适用于常规UIView 类型的应用程序。
标签: objective-c ios cocoa-touch animation calayer