Skip to content

Instantly share code, notes, and snippets.

@asingh33
Created May 9, 2021 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asingh33/50e61bb3dd0247b39fb5d2082fef749b to your computer and use it in GitHub Desktop.
Save asingh33/50e61bb3dd0247b39fb5d2082fef749b to your computer and use it in GitHub Desktop.
Context based Draw function, which does the actual rendering of annotations.
// 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