I'm trying to build a interface that the user can move his finger around the screen an a list of images moves along a path. The idea is that the images center nevers leaves de path.
Most of the things I found was about how to animate using CGPath and not about actually using the path as the track to a user movement.
I need to objects to be tracked on the path even if the user isn't moving his fingers over the path.
For example (image bellow), if the object is at the beginning of the path and the user touches anywhere on the screen and moves his fingers from left to right I need that the object moves from left to right but following the path, that is, going up as it goes to the right towards the path's end.
This is the path I've draw, imagine that I'll have a view (any image) that the user can touch and drag it along the path, there's no need to move the finger exactly over the path. If the user move from left to right the image should move from left to right but going up if need following the path.
This is how I'm creating the path:
CGPoint endPointUp = CGPointMake(315, 124);
CGPoint endPointDown = CGPointMake(0, 403);
CGPoint controlPoint1 = CGPointMake(133, 187);
CGPoint controlPoint2 = CGPointMake(174, 318);
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, endPointUp.x, endPointUp.y);
CGPathAddCurveToPoint(path, NULL, controlPoint1.x, controlPoint1.y, controlPoint2.x, controlPoint2.y, endPointDown.x, endPointDown.y);
Any idead how can I achieve this?