我想制作一个工具来制作应用程序屏幕的视频,以向客户展示应用程序是如何工作的。
所以我想每 30 - 60 次每秒获取一次窗口截图并将其保存到文档中。应用程序关闭后,从该文件创建视频,然后您将拥有应用程序的视频。当您将应用程序发送到应用商店时,您将删除或取消以制作视频和应用程序截图。
//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?
我怎样才能做到这一点?