0

I have 4 circles created on the same way:

var circleText1 = UIBezierPath(arcCenter: CGPoint(x: labelOrigin.frame.origin.x - 10,y: labelOrigin.frame.origin.y + labelOrigin.frame.height/2), radius: 5, startAngle: CGFloat(0), endAngle:CGFloat(M_PI * 2), clockwise: true)

let shapeLayerCircle1 = CAShapeLayer()
shapeLayerCircle1.path = circleText1.CGPath
shapeLayerCircle1.fillColor = colorArrow.CGColor
self.container.layer.addSublayer(shapeLayerCircle1)

With its respective frames, and I'd like to make the user able to join the buttons to make a word, letter W. More or less like that game we have all played enter image description here

How can I draw the line between the points? I have thought of making it with UIPanGestureRecognizer but don't know who will I draw the line between these 2, and then start the new line with the next point.

Sergio
  • 82
  • 7
  • Is your question about line drawing or about gesture recognizing? – Avt Apr 14 '16 at 20:52
  • I think both are related to my question, as it is how can I detect where the user taps and drag to the other point, and at the same time animate the line drawing. For the line Drawing I'll check what @simon-moshenko says [link](https://github.com/ooper-shlab/GLPaint1.13-Swift/blob/master/Classes/PaintingView.swift) and see how can I incorporate it there. Is that correct? Just selecting the origin point the first dot and the last point the final dot? – Sergio Apr 14 '16 at 20:55

1 Answers1

1

RMPaint pod in RMCanvasView.h has a method renderLineFromPoint which you can use. But you will need to create this RMCanvasView, use the example in the github repository if you have a struggle.

Simon Moshenko
  • 2,028
  • 1
  • 15
  • 36
  • Thank you for your reply. I have checked what your link says, that the swift repo [link](https://github.com/ooper-shlab/GLPaint1.13-Swift/blob/master/Classes/PaintingView.swift) After adding that method, I need to put the origin point on the first dot and the final point on the final dot, and then add the pangesturerecognizer. Will this detect when the user starts dragging from the first dot to the second one? – Sergio Apr 14 '16 at 20:57
  • @Sergio you will probably need to manualy check if UITouches are in the necessery for you radiuse around your first dot. And then paint a line from your first dot to the current touch possition and clear each time untill the second dot is achived. Save it on some kind of background image(TMCanvasView has snapshotImage(as i remember)). And so on – Simon Moshenko Apr 14 '16 at 21:05