PDFKit iOS 11:如何更改Ink批注的线宽? [英] PDFKit iOS 11: How to change the line width of Ink annotation?

查看:155
本文介绍了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)

就足够了,因为在核心图形中绘制时,修改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批注的线宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆