Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 捕获uiwindow屏幕截图,以每秒30帧的速度播放ui动画_Iphone_Ios_Ipad_Core Animation_Screenshot - Fatal编程技术网

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动画。我正在努力解决这个问题