【发布时间】:2018-08-06 15:45:09
【问题描述】:
我想使用 PDFKit 在 pdf 文件中添加高亮注释。我使用下面的代码来添加它。
PDFPage* page = [self.pdfView.document pageAtIndex:0];
PDFAnnotation* annotation = [[PDFAnnotation alloc] initWithBounds:CGRectMake(206, 600, 60, 59) forType:PDFAnnotationSubtypeHighlight withProperties:nil];
annotation.color = UIColor.blueColor;
[page addAnnotation:annotation];
但它只是突出显示一个矩形,我想突出显示多行文本。我找到了一个问题/答案Wrong highlight annotation on apple PDFKit
但这不是我想要的,它会添加很多高亮注释,我只想添加一个注释。我了解到键值 QuadPoints 可以做到这一点。但是当我添加下面的代码时它不起作用,甚至无法渲染注释。
NSArray<NSValue *> *quadrilateralPoints = [[NSArray alloc] initWithObjects:
[NSValue valueWithCGPoint:CGPointMake(206.0f, 659.0f)],
[NSValue valueWithCGPoint:CGPointMake(266.0f, 659.0f)],
[NSValue valueWithCGPoint:CGPointMake(206.0f, 600.0f)],
[NSValue valueWithCGPoint:CGPointMake(266.0f, 600.0f)],
nil];
annotation.quadrilateralPoints = quadrilateralPoints;
所以现在我想知道如何实现它?或者如何使用 quadrilateralPoints ?
【问题讨论】:
标签: ios objective-c swift pdf pdfkit