本文介绍了PDFKit iOS 11:如何更改 Ink 注释的线宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PDFKit 在 PDF 文件上绘制一些墨迹注释.但我不能改变线条的宽度.我认为这样做:

I'm drawing some ink annotations on a PDF file using PDFKit. But I can't change the width of the lines. I thought that doing:

let path = UIBezierPath()
path.lineWidth = 20 // important line
path.move(to: originPoint)
path.addLine(...)
annotation.add(path)

就足够了,因为在 Core Graphics 中绘制时修改 Bezier 路径的 lineWidth 有效.但在这里,它并没有改变任何东西,那么如何改变注释的线宽?

would be enough since modifying the lineWidth of a Bezier path works when drawing in Core Graphics. But here, it does not change anything, so how to change the line width of an annotation ?

推荐答案

使用 PDFAnnotationborder 属性来改变添加到的 UIBezierPath 的粗细

Use border property of PDFAnnotation to change thickness of UIBezierPath added to it.

let p = UIBezierPath()
p.move(to: CGPoint(x: 400, y: 200))
p.addLine(to: CGPoint(x: 500, y: 100))
p.addLine(to: CGPoint(x: 400, y: 0))
p.close()

let b = PDFBorder()
b.lineWidth = 10.0

let pageBounds = page.bounds(for: .artBox)
let inkAnnotation = PDFAnnotation(bounds: pageBounds, forType: PDFAnnotationSubtype.ink, withProperties: nil)
inkAnnotation.add(p)
inkAnnotation.border = b
inkAnnotation.color = .green

page.addAnnotation(inkAnnotation)

这篇关于PDFKit iOS 11:如何更改 Ink 注释的线宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-11 07:18