简体   繁体   English

iOS Swift PDFKit小部件子类型按钮边框

[英]iOS Swift PDFKit Widget Subtype button border

I'm working with PDFKit, and I'm looking to add a PDF Annotation that supports the user selecting/deselecting it. 我正在使用PDFKit,并且希望添加一个支持用户选择/取消选择它的PDF注释。 I'm using PDFAnnotationWidgetSubtype.button and I can't find a way to remove the border. 我正在使用PDFAnnotationWidgetSubtype.button ,但找不到删除边框的方法。 I've tried subclassing PDFBorder to no avail, has anyone else has experience with this? 我尝试将PDFBorder子类无济于事,还有其他人对此有经验吗?

带有边框的复选框

ANSWER 回答

My solution to this problem was to create my own PDFAnnotation subclass. 解决此问题的方法是创建自己的PDFAnnotation子类。

var isChecked = false

init(forBounds bounds: CGRect, withProperties properties: [AnyHashable : Any]?)

override func draw(with box: PDFDisplayBox, in context: CGContext)

I used the isChecked property inside of the draw function. 我在draw函数中使用了isChecked属性。 If the property was toggled on, then I was display a checkmark image I found on Icons8. 如果启用了该属性,那么将显示在Icons8上找到的对勾图像。 I also had to add the PDFAnnotationHitObserver in my ViewController, and handled updating the property of isChecked. 我还必须在ViewController中添加PDFAnnotationHitObserver,并处理了isChecked属性的更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM