I managed to create a function called dash_line in swift to create dash line between 2 points:
<code> context_dash.setStrokeColor(color!.cgColor)
context_dash.setLineWidth(strokeWidth)
let dashArray:[CGFloat] = [d1,d2,d3,d4]
context_dash.setLineDash(phase: strokeWidth, lengths: dashArray)
context_dash.move(to: CGPoint(x: p1.x, y: p1.y))
context_dash.addLine(to: CGPoint(x: p2.x, y: p2.y))
context_dash.drawPath(using: CGPathDrawingMode.stroke)
</code>
<code> context_dash.setStrokeColor(color!.cgColor)
context_dash.setLineWidth(strokeWidth)
let dashArray:[CGFloat] = [d1,d2,d3,d4]
context_dash.setLineDash(phase: strokeWidth, lengths: dashArray)
context_dash.move(to: CGPoint(x: p1.x, y: p1.y))
context_dash.addLine(to: CGPoint(x: p2.x, y: p2.y))
context_dash.drawPath(using: CGPathDrawingMode.stroke)
</code>
context_dash.setStrokeColor(color!.cgColor)
context_dash.setLineWidth(strokeWidth)
let dashArray:[CGFloat] = [d1,d2,d3,d4]
context_dash.setLineDash(phase: strokeWidth, lengths: dashArray)
context_dash.move(to: CGPoint(x: p1.x, y: p1.y))
context_dash.addLine(to: CGPoint(x: p2.x, y: p2.y))
context_dash.drawPath(using: CGPathDrawingMode.stroke)
If I call first this function dash_Line, I can see a dash line between pointA and pointB, but all lines created by another function called continuous_Line became dash line.
This is happening only if I call dash_Line function first.
But if I called the continuous_Line first, all the line created by this function aer continuous.
What codes I need to add in the dash_Line function in order not to affect the other functions.