Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Easiest way would be subclassing <code>UIImageView</code>.</p> <p>For simple dragging take a look at the code here (code borrowed from user MHC): </p> <p><a href="https://stackoverflow.com/questions/4982277/uiview-drag-image-and-text/8332581#8332581">UIView drag (image and text)</a></p> <p>Since you want to drag along Bezier path you'll have to modify <code>touchesMoved:</code></p> <pre><code> -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *aTouch = [touches anyObject]; //here you have location of user's finger CGPoint location = [aTouch locationInView:self.superview]; [UIView beginAnimations:@"Dragging A DraggableView" context:nil]; //commented code would simply move the view to that point //self.frame = CGRectMake(location.x-offset.x,location.y-offset.y,self.frame.size.width, self.frame.size.height); //you need some kind of a function CGPoint calculatedPosition = [self calculatePositonForPoint: location]; self.frame = CGRectMake(calculatedPosition.x,calculatedPosition.y,self.frame.size.width, self.frame.size.height); [UIView commitAnimations]; } </code></pre> <p>What exactly you would like to do in <code>-(CGPoint) calculatePositionForPoint:(CGPoint)location</code> is up to you. You could for example calculate point in Bezier path that is the closest to <code>location</code>. For simple test you can do:</p> <pre><code>-(CGPoint) calculatePositionForPoint:(CGPoint)location { return location; } </code></pre> <p>Along the way you're gonna have to decide what happens if user <em>wonders off</em> to far from your precalculated Bezier path.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload