title: How can I make a UIImageView follow a certain path?
body: <p>I have drawn an arc using:</p>
  
  <pre><code>CGContextRef context = UIGraphicsGetCurrentContext();
      CGContextSetLineWidth(context, 4.0);
      CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
      CGContextMoveToPoint(context, 0,300);
      CGContextAddArcToPoint(context, 125,300, 125,480, 180);//last value is the radius
      CGContextStrokePath(context);
  </code></pre>
  
  <p>My goal is to place a UImageView at the starting coordinate of this arc and use a UIPanGestureRecognizer to slide it along this arc. Right now I am getting the gesture translation using this line: <code>CGPoint translate = [sender translationInView:self.view];</code>
  the <code>sender</code> is a <code>UIPanGestureRecognizer</code> type.</p>
  
  <p>The image should slide down the arc as long as <code>translate.x</code> moves in a positive direction (<strong>-------></strong>)</p>
  
  <p>Currently I have the image starting at the coordinate <code>(0,300)</code>, which is the same starting coordinate for the arc. The image responds to the gesture on the x-axis but the y-value stays at <code>300</code>. How can I keep a limit on the point <code>translate</code> so that it follows the coordinates of the arc I created?</p>
  
  <p>This is what I currently have, all it does is slide out on the x-axis:</p>
  
  <pre><code>-(void)slide:(UIPanGestureRecognizer *)sender
  {
      if([sender state] == UIGestureRecognizerStateBegan)
      {
  
          startPos = CGPointMake(0, 300);
  
          minPos = CGPointMake(0, 300);
  
          maxPos = CGPointMake(125, 480);
  
      }
  
      else if ([sender state] == UIGestureRecognizerStateChanged)
      {
          CGPoint translate = [sender translationInView:self.view];
          CGPoint newPos;
  
          newPos = CGPointMake(startPos.x + translate.x, startPos.y);
  
          //CGPoint newYPos = CGPointMake(startPos.x + translate.x, &lt;#CGFloat y#&gt;)
  
          if(newPos.x &lt; minPos.x)
          {
              newPos.x = minPos.x;
              translate = CGPointMake(newPos.x - startPos.x, minPos.y);
          }
          if(newPos.x &gt;= maxPos.x)
          {
              newPos.x = maxPos.x; 
              translate = CGPointMake(newPos.x - startPos.x, maxPos.y);
          }
  
          [sender setTranslation:translate inView:self.view];
  
          self.handle.center = newPos; //handle is a UIImageView
      }
  }
  </code></pre>
  
  <p>I think the problem lies in the two <code>if</code> statements I use to limit the x-value. I'm just unsure of how to limit both the x&amp;y-value of <code>CGPoint translate</code> to follow a set curve.</p>
  
  <p>Any help at all is greatly appreciated.</p>