我想创建一个工具,制作应用程序屏幕的视频,以显示应用程序如何为客户端工作
所以我希望每秒30到60次获取窗口截图,并将其保存到文档中。应用关闭后,根据这些文件创建视频,然后您将获得应用的视频。当您将应用程序发送到appstore时,您将删除或取消制作视频和应用程序sreenshots。
//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?
我怎么能这样做?
答案 0 :(得分:3)
使用此
[layer.presentationLayer renderInContext:UIGraphicsGetCurrentContext()];
而不是
[layer renderInContext:UIGraphicsGetCurrentContext()];
答案 1 :(得分:0)
它可能对你有帮助。: -
https://github.com/hackiftekhar/IQProjectVideo
它有一个缺点,它不捕获presentViewController动画。我想解决这个问题。