1

我正在加载 3 个不同的 PDF 文件并干燥以使用 drawLayer 将它们绘制到 3 个 UIviews 中。这可行,但它们都是 3 被绘制到一个 UIview 的同一层中。我需要将它们分别绘制到自己的 UIView 中,但我不知道如何将这段代码解析为三个部分。请问有什么想法吗?

// This method takes care of the cropping and adds each PDF layer to the view
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context {
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(context, CGContextGetClipBoundingBox(context));
CGContextTranslateCTM(context, 0.0, layer.bounds.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(mappageRef, kCGPDFCropBox, layer.bounds, 0, true));
CGContextDrawPDFPage(context, mappageRef);
CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(vorpageRef, kCGPDFCropBox, layer.bounds, 0, true));
CGContextDrawPDFPage(context, vorpageRef);
CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(labelpageRef, kCGPDFCropBox, layer.bounds, 0, true));
CGContextDrawPDFPage(context, labelpageRef);
}
4

1 回答 1

0

CALayer 属于单个 UIView,只负责绘制它自己,而不是其他层。您需要控制器将每个 PDF 文件发送到正确的视图,并让每个视图在自己的图层中绘制它。

于 2012-02-29T17:47:16.360 回答