iOS---------wkwebview获取缩略图

获取wkwebview的缩略图   wkwebview截屏    

-(void) screenShot{
    
  UIGraphicsBeginImageContext(self.bounds.size);   //self为需要截屏的UI控件 即通过改变此参数可以截取特定的UI控件 
  [self.layer renderInContext:UIGraphicsGetCurrentContext()];    
  UIImage *image= UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();    
  NSLog(@"image:%@",image); //至此已拿到image

  UIImageView *imaView = [[UIImageView alloc] initWithImage:image];   
  imaView.frame = CGRectMake(0, 700, 500, 500);    
  [self addSubview:imaView];    
    
  UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);//把图片保存在本地
}
 

 

https://www.jianshu.com/p/653400bb619c

https://www.jianshu.com/p/65f86f24a515

posted @ 2021-01-04 11:23  iOS张文权  阅读(204)  评论(0编辑  收藏  举报