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;