美文网首页
IOS开发之截图(视频播放)

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

作者: 云飘雾散 | 来源:发表于2016-10-12 02:42 被阅读0次

    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;
    

    相关文章

      网友评论

          本文标题:IOS开发之截图(视频播放)

          本文链接:https://www.haomeiwen.com/subject/kqtiyttx.html