I´m trying to animate a sort of draggable UIView where the behaviour should be something like this:
- Drag along the screen following the touch of the user.
- Detect a swipe touch and drag automatically with an initial speed and a negative acceleration that makes is stop after some time.
Something like moving around a photo and then through it to one side of the screen.
Any tips on this?
A similar question was asked (by me) about 3 weeks ago. Though some of the answers I received were a little off the mark the best advice was: 1- study Apple’s MoveMe example for how to touch an object and drag it around. And 2- you “throw” the object by basically comparing the [touch locationInView:self.view] to the [touch previousLocationInView:self.view] in touchesEnded (could also store a reference to first touch in touchesBegan but I find that less helpful as user may pause) using the time stamp of each you can determine the direction of swipe (flick) and rate of speed and use them to send your little UIView flying around. Obviously you want to apply forces (“friction”) or whatever to slow it down so it doesn’t fly right of your screen…