I am using swift 4.
I wrote the code below and tried to draw a circle with stroke.
However, with the code below I could not draw my desired circle.
The problem is that the line is drawn from the center of the circle to the outer periphery
(strictly speaking, toward the coordinate point of the 'startAngle' property).
I want to erase the line, what should I do?
(I prepared an image.)
class Something{
var line:[CAShapeLayer] = []
var path:[UIBezierPath] = []
func drawingNow(){
let layer = CAShapeLayer()
self.layer.addSublayer(layer)
self.line.append(layer)
let addPath: UIBezierPath = UIBezierPath()
addPath.move(to: CGPoint(x: 100, y: 100))
addPath.addArc(
withCenter: CGPoint(x: 100, y: 100),
radius: CGFloat(50),
startAngle: CGFloat(//someangle),
endAngle: CGFloat(//someangle),
clockwise: true
)
self.path.append(addPath)
//self.line.last!.strokeColor = etc... (If don't use "override func draw()")
self.line.last!.fillColor = UIColor.clear.cgColor
self.line.last!.path = addPath.cgPath
self.setNeedsDisplay()
}
override func draw(_ rect: CGRect) {
if self.path.count != 0{
UIColor.orange.setStroke()
self.path.last!.stroke()
}
}
}