我想制作一个可以在您的应用程序屏幕上播放视频的工具,以向客户端显示应用程序的工作方式。
所以我想每秒获取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()];
代替[layer renderInContext:UIGraphicsGetCurrentContext()];