IOS开发之截图(视频播放)

IOS开发截图常用方法如下:

@property (nonatomic,strong) UIView *container;
- (void)shotScreen{
        UIGraphicsBeginImageContext(_container.bounds.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
        //[self.view drawViewHierarchyInRect:self.container.bounds afterScreenUpdates:YES];
        [self.view.layer renderInContext:context];
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        UIImageWriteToSavedPhotosAlbum(newImage, self, nil, nil);
}

通过上面的方法可以截取静态的图形,但无法截取正在播放的视频,而有时我们却需要截取视频播放时的图形,其实很简单只需要在上面的方法中UIView类提供的一个方法:

   - (void)drawViewHierachyInRect: afterScreenUpdates;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容