IOS開發(fā)截圖常用方法如下:
@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);
}
通過上面的方法可以截取靜態(tài)的圖形济舆,但無法截取正在播放的視頻漓骚,而有時我們卻需要截取視頻播放時的圖形蛙埂,其實很簡單只需要在上面的方法中UIView類提供的一個方法:
- (void)drawViewHierachyInRect: afterScreenUpdates;