【发布时间】:2019-04-09 06:09:26
【问题描述】:
我尝试在 pdf 中为页面添加注释。有用。但不在所需的位置。这是我添加注释的方式。
let annotaionpos = CGRect(origin: points, size: CGSize(width: 80, height: 30))
let annotation = PDFAnnotation(bounds: annotaionpos, forType: .text, withProperties: nil)
annotation.backgroundColor = .purple
pdfView.currentPage?.addAnnotation(annotation)
在上面的代码中,x position 是正确的,y position 似乎是相反的值。 ex: if x = 100 and y = 10 然后它从页面底部添加到正确的x 位置 和y 位置星。为什么是这样。希望您对此有所帮助。
【问题讨论】:
-
你好马龙,你能分享一下预期结果的截图吗?
-
因为 PDF 坐标是这样定义的。 “原点或 0,0 点位于页面的左下角。水平或 X 坐标向右增加,垂直或 Y 坐标向顶部增加”pdfscripting.com/public/PDF-Page-Coordinates.cfm
标签: ios swift pdfkit pdf-annotations