tableview 截图

- (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 截图)