I am trying to draw a line with a smooth quadratic curve attached to its end. Therefore, I am using this code:
import Foundation
import UIKit
class IndicatingView: UIView {
var path: UIBezierPath!
override init(frame: CGRect) {
super.init(frame: frame)
}
func createLineWithCurve() {
path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: 0))
path.addLine(to: CGPoint(x: 0, y: self.frame.height - self.frame.width))
path.addQuadCurve(to: CGPoint(x: self.frame.width, y: self.frame.height), controlPoint: CGPoint(x: 0, y: self.frame.height))
}
override func draw(_ rect: CGRect) {
self.createLineWithCurve()
path.lineWidth = 3
// Specify a border (stroke) color.
UIColor.purple.setStroke()
path.stroke()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
And the output I get looks quite good already:
However, as you can see, the quad-curve is fatter than the normal line. Also, the quad-curve seems to be cut off at the bottom. How can I fix that? I want the path to be completely smooth without looking fatter at some points or being cut-off somehow.
Thanks in advance for your help :)