CALayer and Off-Screen Rendering

后端 未结 1 550
自闭症患者
自闭症患者 2020-12-15 00:52

I have a Paging UIScrollView with a contentSize large enough to hold a number of small UIScrollViews for zooming, The viewForZoomingInScrollView is

相关标签:
1条回答
  • 2020-12-15 01:26

    As i mentioned above, CALayers don't render if they are offscreen.

    I ended up not drawing the PDF directly to the layer but instead, rendered the PDF page to an image when i needed (renders 1 page plus and minus one of the focused page)

    Here is the render code:

    -(UIImage *)renderPDFPageToImage:(int)pageNumber//NSOPERATION?
    {
     //you may not want to permanently (app life) retain doc ref
    
     CGSize size = CGSizeMake(x,y);     
     UIGraphicsBeginImageContext(size);
     CGContextRef context = UIGraphicsGetCurrentContext();
    
     CGContextTranslateCTM(context, 0, 750);
     CGContextScaleCTM(context, 1.0, -1.0);
    
     CGPDFPageRef page;  //Move to class member 
    
        page = CGPDFDocumentGetPage (myDocumentRef, pageNumber);
        CGContextDrawPDFPage (context, page);
    
     UIImage * pdfImage = UIGraphicsGetImageFromCurrentImageContext();//autoreleased
     UIGraphicsEndImageContext();
     return pdfImage;
    
    }
    
    0 讨论(0)
提交回复
热议问题