IOS SDK - how to screen shot content of tableView?

后端 未结 3 1409
情书的邮戳
情书的邮戳 2020-12-30 08:47

How to screen-shot ALL content of tableView? (all content = visible are + NOT visible area)

I tried this:

UIGraphicsBeginImageContext(self.tableView.         


        
3条回答
  •  醉话见心
    2020-12-30 08:58

    + (UIImage *)captureView:(UIScrollView *)view inContentRect:(CGRect)rect{
        UIImage* image = nil;
    
        CGPoint savedContentOffset = view.contentOffset;
        CGRect savedFrame = view.frame;
    
        UIGraphicsBeginImageContextWithOptions(view.contentSize, 1, 0);
        view.contentOffset = CGPointZero;
        view.frame = CGRectMake(0, 0, view.contentSize.width, view.contentSize.height);
    
        [view.layer renderInContext: UIGraphicsGetCurrentContext()];
        image = UIGraphicsGetImageFromCurrentImageContext();
    
        view.contentOffset = savedContentOffset;
        view.frame = savedFrame;
    
        UIGraphicsEndImageContext();
    
        // after all of this, crop image to needed size
        return [Utils cropImage:image toRect:rect];                                 
    }
    

提交回复
热议问题