如何在 PDFView Swift 中显示旋转图像 PDFAnnotation?

问题描述

关于在 PDFView 中显示旋转图像 PDFAnnotation,我需要您的建议。我使用以下内容显示旋转后的图像 PDFAnnotation。

override func draw(with Box: PDFdisplayBox,in context: CGContext) {
            
    let drawingBox = self.page?.bounds(for: Box)
    
    UIGraphicsPushContext(context)
    context.saveGState()
    context.translateBy(x: bounds.midX,y: bounds.midY)
    context.rotate(by: 0.7310428063040626)
    context.translateBy(x: -bounds.midX,y: -bounds.midY)
    guard let cgImage = image.cgImage else { return }
   
    context.draw(cgImage,in: self.bounds.applying(CGAffineTransform(
           translationX: (drawingBox?.origin.x)! * -1.0,y: (drawingBox?.origin.y)! * -1.0)))

    context.restoreGState()
    UIGraphicsPopContext()        
}

问题是在 draw 方法中旋转图像时,由于旋转的图像不适合 PDFAnnotation 边界,图像的某些部分被截断。

Cropped Image

我需要您就我们如何解决此问题提出建议。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)