0

我正在加载 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在“旋转”中......我该怎么做?

谢谢,史蒂夫

4

2 回答 2

0

要发出需要重绘图层的信号,请向其发送setNeedsDisplayorsetNeedsDisplayInRect:消息。您必须将所需的旋转角度存储在 ivar/property 中并从drawLayer:inContext:.

于 2011-03-06T15:37:17.053 回答
0

尝试在您的图层上调用 setNeedsDisplay

于 2011-03-06T15:43:45.293 回答