Iphone 捕获uiwindow屏幕截图,以每秒30帧的速度播放ui动画
我想制作一个工具,用于制作应用程序屏幕的视频,向客户端显示应用程序的工作方式。Iphone 捕获uiwindow屏幕截图,以每秒30帧的速度播放ui动画,iphone,ios,ipad,core-animation,screenshot,Iphone,Ios,Ipad,Core Animation,Screenshot,我想制作一个工具,用于制作应用程序屏幕的视频,向客户端显示应用程序的工作方式。 所以我想每秒30-60次获得窗口截图,并将其保存到文档中。应用程序关闭后,从该文件创建一个视频,然后您将有一个应用程序的视频。当您将应用程序发送到appstore时,您将删除或取消以制作视频和应用程序重新拍摄 //Get list of document directories in sandbox NSArray *documentDirectories = NSSearchPathForDirectori
所以我想每秒30-60次获得窗口截图,并将其保存到文档中。应用程序关闭后,从该文件创建一个视频,然后您将有一个应用程序的视频。当您将应用程序发送到appstore时,您将删除或取消以制作视频和应用程序重新拍摄
//Get list of document directories in sandbox
NSArray *documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDirectory, YES);
//Get one and only document directory from that list
self.documentFolder = [documentDirectories objectAtIndex:0];
self.images = [[NSMutableArray alloc] init];
//Append passed in file name to that directory, return it
_counter = 0;
self.timerCapture = [NSTimer scheduledTimerWithTimeInterval: 1.0f/30.0f
target: self
selector: @selector(getWindowCapture:)
userInfo: nil
repeats: YES];
- (UIImage *)captureScreen {
CALayer *layer;
layer = self.window.layer;
UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, 1.0f);
[layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return screenImage;
}
问题是我无法在动画期间捕获UIWindow
我该怎么做呢?使用这个
[layer.presentationLayer renderInContext:UIGraphicsGetCurrentContext()]代码>
而不是
[图层渲染上下文:UIGraphicsGetCurrentContext()]代码>使用此
[layer.presentationLayer renderInContext:UIGraphicsGetCurrentContext()]代码>
而不是
[图层渲染上下文:UIGraphicsGetCurrentContext()]代码>它可能会帮助您:-
它有一个缺点,它不能捕获presentViewController动画。我正在努力解决这个问题。它可能会对您有所帮助-
它有一个缺点,它不能捕获presentViewController动画。我正在努力解决这个问题