Created
May 9, 2021 16:11
-
-
Save asingh33/50e61bb3dd0247b39fb5d2082fef749b to your computer and use it in GitHub Desktop.
Context based Draw function, which does the actual rendering of annotations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Context based Draw function, which does the actual rendering of annotations. | |
override func draw(with box: PDFDisplayBox, in context: CGContext) { | |
if( path == nil){ | |
return | |
} | |
let localPath = path.copy() as! UIBezierPath | |
super.draw(with: box, in: context) | |
// Draw a custom purple line. | |
UIGraphicsPushContext(context) | |
context.saveGState() | |
localPath.lineWidth = stencilWidth | |
localPath.lineJoinStyle = .round | |
localPath.lineCapStyle = .round | |
stencilColor.setStroke() | |
localPath.stroke(with: CGBlendMode.sourceOut, alpha: 0.4) | |
//localPath.usesEvenOddFillRule = true | |
context.restoreGState() | |
UIGraphicsPopContext() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment