ios - PDFKit iOS 11 : How to change the line width of Ink annotation?

标签 ios swift annotations pdfkit

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

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

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

最佳答案

使用 PDFAnnotationborder 属性来更改添加到其中的 UIBezierPath 的粗细。

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)

关于ios - PDFKit iOS 11 : How to change the line width of Ink annotation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48938804/

相关文章:

swift - MBProcessHud 未在 Alamofire 中快速加载

java - 使用注释的依赖注入(inject)如何在内部工作,无论它是调用 setter 方法还是基于构造函数的注入(inject)

ios - 在后台 iOS 中重新连接 BLE 设备

ios - 在 MapBox Android 和 iOS 上显示 GeoJSON

android - 为什么android sdk中默认的proguard配置使用keep *注释*

java - 如何在不使用 xml 或注释的情况下使 Spring 识别 bean?

ios - 突出显示时如何从 UIButton 中删除 CAGradientLayer

ios - 返回类型为空

ios - 什么会导致 NSUserDefaults 被清除

没有标签的 iOS 7 NavigationBar 后退按钮自定义图像