简体   繁体   中英

Clip part of the page of PDF while drawing in iOS

I am over-riding the drawLayer method to draw a particular page of the pdf. How can I clip a part of the page and show the same.

 - (void)drawLayer:(CATiledLayer *)layer inContext:(CGContextRef)context
    {   
     CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); // White

            CGContextFillRect(context, CGContextGetClipBoundingBox(context)); // Fill


            CGContextTranslateCTM(context, 0.0f, self.bounds.size.height); CGContextScaleCTM(context, 1.0f, -1.0f);

            CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(_PDFPageRef, kCGPDFCropBox, self.bounds, 0, true));


            CGContextDrawPDFPage(context, _PDFPageRef);

    }

如果在绘制PDF页面之前在上下文中设置了剪切区域,则可以剪切页面的一部分。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM