CGContext strokepath makes edges of stroke blurred

111 Views Asked by At

I'm working on a simple freehand drawing app. Below is the sample code, I'm using the UIGesture class to track the scribble, i.e., pencil or finger movement, and then stroking those touch points on the UIImageView

    let previousLocation = touch.previousLocation(in: self)
    let location = touch.location(in: self)
    var lineWidth: CGFloat = 3
    UIColor.black.setStroke()
    context?.setLineWidth(lineWidth)
    context?.setLineCap(.round)
    context?.move(to: previousLocation)
    context?.addLine(to: location)
    context?.strokePath() 

the strokes are blurry on the edges and the result looks like this:

enter image description here

Few other things I have tried: 1)Stroking bezier pathh 2)Using view instead of image view 3)Increasing scale here -> UIGraphicsBeginImageContextWithOptions, this does increase the sharpness but the overall writing lags

How do I get sharp annotations?

0

There are 0 best solutions below