美文网首页
tableview 截图

tableview 截图

作者: hypercode | 来源:发表于2018-10-25 18:29 被阅读0次
    - (UIImage *)captureScrollView:(UIScrollView *)scrollView
    {
        UIImage* image = nil;
    //    UIGraphicsBeginImageContextWithOptions(CGSizeMake(APP_SCREEN_WIDTH, 1000), NO, 0.0);
        UIGraphicsBeginImageContextWithOptions(scrollView.contentSize, NO, 0.0);
        {
            CGPoint savedContentOffset = scrollView.contentOffset;
            CGRect savedFrame = scrollView.frame;
            scrollView.contentOffset = CGPointZero;
            scrollView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height);
            
            [scrollView.layer renderInContext: UIGraphicsGetCurrentContext()];
            image = UIGraphicsGetImageFromCurrentImageContext();
            
            scrollView.contentOffset = savedContentOffset;
            scrollView.frame = savedFrame;
        }
        UIGraphicsEndImageContext();
        
        if (image != nil) {
            return image;
        }
        return nil;
    }
    
    
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                NSLog(@"%.f",self.viewContainer.frame.size.height);
                _scrollViewMain.contentSize = CGSizeMake(APP_SCREEN_WIDTH,self.tableViewMain.contentSize.height);
            });
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    

    相关文章

      网友评论

          本文标题:tableview 截图

          本文链接:https://www.haomeiwen.com/subject/emvctqtx.html