IOS development implementation code for ios video screenshots
There are many video screenshot software now. Here is a method for IOS video screenshots. You can refer to it.
Implementation code:
//screenshotstatic int i=0; -(IBAction)screenShot:(id)sender{ UIGraphicsBeginImageContextWithOptions(CGSizeMake(640, 960), YES, 0); [[ layer] renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); CGImageRef imageRef = ; CGRect rect =CGRectMake(166, 211, 426, 320);// Here you can set the area you want to take a screenshot CGImageRef imageRefRect =CGImageCreateWithImageInRect(imageRef, rect); UIImage *sendImage = [[UIImage alloc] initWithCGImage:imageRefRect]; UIImageWriteToSavedPhotosAlbum(sendImage, nil, nil, nil);//Save pictures to photo library NSData *imageViewData = UIImagePNGRepresentation(sendImage); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *pictureName= [NSString stringWithFormat:@"screenShow_%",i]; NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:pictureName]; NSLog(@"%@", savedImagePath); [imageViewData writeToFile:savedImagePath atomically:YES];//Save photos to sandbox directory CGImageRelease(imageRefRect); i++; }
Thank you for reading, I hope it can help you. Thank you for your support for this site!