我正在加载 CGPDFDocument,将其作为子层添加到 UIView (myContentView),然后将 myContentView 添加到 UIScrollView。这很好用。现在我想允许用户选择旋转 PDF。很容易让 PDF 最初显示一些旋转 - 我只是在这里做:
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
CGContextSaveGState (ctx);
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx));
CGContextTranslateCTM(ctx, 0.0, layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(myPageRef, kCGPDFCropBox, layer.bounds, rotation, true));
CGContextDrawPDFPage(ctx, myPageRef);
CGContextRestoreGState (ctx);
}
但是,在初始加载后我该怎么做呢?
注意:我尝试只旋转 myContentView,这似乎可行,但在这样做之后,我无法再缩放/取消缩放 PDF ......我认为我需要强制使用新值再次调用 drawLayer在“旋转”中......我该怎么做?
谢谢,史蒂夫