2
votes

I wish to emulate this effect in Xcode with Swift. After some research I managed to find some articles about drawing smooth curves using a set of points .But I am still unclear about how I could to dynamically modify curves when the user touches/holds the screen.

Question :

I know how to make a smooth Bezier curve, but how can I add gesture recognizers such that by dragging the curve its shape changes.

I only need someone to point me in the right direction. Is there a guide or article in particular that could be useful?

1
You have a very good answer. Please understand that you simply cannot add gestures to a bezier path. - dfd
But there must be some way to recreate the effect here : mbostock.github.io/protovis/ex/splines.html - user7404038

1 Answers

1
votes
  1. Create transparent ControlPointView for every control point of the curve with a size of 50*50pt, so that users can easily tap them and drag.
  2. Add a small image in the middle of every ControlPointView, so that users can see where the control point is located.
  3. Add UIPanGestureRecognizer on every ControlPointView and handle it in view controller.
  4. Use centers of control points to rebuild UIBezierPath every time gesture recognizer's state is changed.