全屏截取webview内容

按钮事件

-(IBAction)btnClick:(id)sender

{
    NSArray *arr = [webview subviews];
    UIScrollView *scrollview = [arr objectAtIndex:0];
    CGSize sixzevid=scrollview.contentSize;
    CGPoint oriOffsetPoint = scrollview.contentOffset;
    CGRect oriFrame = webview.frame;
    webview.frame = CGRectMake(0, 0, sixzevid.width, sixzevid.height);
    UIGraphicsBeginImageContext(sixzevid);
    [webview.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSData *imageData = UIImagePNGRepresentation(viewImage);
    UIImageWriteToSavedPhotosAlbum( viewImage, self, nil , nil ) ;
    webview.frame = oriFrame;
    scrollview.contentOffset = oriOffsetPoint;
      NSLog(@"XXXXXX");

}


测试通过


你可能感兴趣的:(全屏截取webview内容)