Created
August 3, 2017 14:37
-
-
Save codePrincess/2a637737a41db63ea79de67dc71442f8 to your computer and use it in GitHub Desktop.
draw rectangle over current drawing area
This file contains hidden or 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
func drawDoodlingRect(context: CGContext?) { | |
let inset = 5 | |
markerColor.setStroke() | |
context!.setLineWidth(1.0) | |
context!.setLineCap(.round) | |
UIColor.clear.setFill() | |
ocrImageRect = CGRect(x: minX - inset, y: minY - inset, width: (maxX-minX) + inset*2, height: (maxY-minY) + 2*inset) | |
context!.addRect(ocrImageRect!) | |
context!.strokePath() | |
drawTextRect(context: context, rect: ocrImageRect!) | |
image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
fetchOCRText() | |
resetDoodleRect() | |
} | |
func drawTextRect(context: CGContext?, rect: CGRect) { | |
UIColor.lightGray.setStroke() | |
currentTextRect = CGRect(x: rect.origin.x, y: rect.origin.y + rect.height, width: rect.width, height: 15) | |
context!.addRect(currentTextRect!) | |
context!.strokePath() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment