最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

IOS 開發(fā)之ios視頻截屏的實現(xiàn)代碼

 更新時間:2017年07月15日 15:54:23   作者:Hi_Aaron  
這篇文章主要介紹了IOS 開發(fā)之ios視頻截屏的實現(xiàn)代碼的相關資料,需要的朋友可以參考下

IOS 開發(fā)之ios視頻截屏的實現(xiàn)代碼

           現(xiàn)在好多視頻截屏軟件,這里提供一個IOS 視頻截屏的方法,大家可以參考下,

實現(xiàn)代碼:

//截屏 
static int i=0; 
-(IBAction)screenShot:(id)sender{ 
   
  UIGraphicsBeginImageContextWithOptions(CGSizeMake(640, 960), YES, 0); 
  [[self.window layer] renderInContext:UIGraphicsGetCurrentContext()]; 
  UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
  UIGraphicsEndImageContext(); 
  CGImageRef imageRef = viewImage.CGImage; 
  CGRect rect =CGRectMake(166, 211, 426, 320);//這里可以設置想要截圖的區(qū)域 
  CGImageRef imageRefRect =CGImageCreateWithImageInRect(imageRef, rect); 
  UIImage *sendImage = [[UIImage alloc] initWithCGImage:imageRefRect]; 
  UIImageWriteToSavedPhotosAlbum(sendImage, nil, nil, nil);//保存圖片到照片庫 
  NSData *imageViewData = UIImagePNGRepresentation(sendImage); 
   
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
  NSString *documentsDirectory = [paths objectAtIndex:0]; 
  NSString *pictureName= [NSString stringWithFormat:@"screenShow_%d.png",i]; 
  NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:pictureName]; 
  NSLog(@"%@", savedImagePath); 
  [imageViewData writeToFile:savedImagePath atomically:YES];//保存照片到沙盒目錄 
  CGImageRelease(imageRefRect); 
  i++; 
} 

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關文章

最新評論

璧山县| 金溪县| 杂多县| 合山市| 遵化市| 元氏县| 澜沧| 延庆县| 五峰| 会昌县| 虞城县| 酒泉市| 娄烦县| 深泽县| 通江县| 佛冈县| 新津县| 东海县| 灯塔市| 古浪县| 布拖县| 新建县| 庆城县| 莱西市| 沁水县| 兴义市| 岱山县| 墨脱县| 清原| 蒲江县| 临猗县| 达州市| 金寨县| 宽城| 宜丰县| 广南县| 黎城县| 宜章县| 江川县| 天镇县| 沙洋县|