Reputation: 7921
i need to drag an element during an animation. The element fall from the top of the screen and i need the user can drag it wherever he want, even during animation Thanks
Upvotes: 0
Views: 275
Reputation: 8001
Since you're using the UIView
block based animations, try using:
animateWithDuration:delay:options:animations:completion:
with the UIViewAnimationOptionAllowUserInteraction
option.
Upvotes: 0
Reputation: 2550
You can use the touchesBegan method to detect when the user touches the element.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if (touch != nil && (touch.view == elementView))
//do your stuff
}
Then set the element's position to the touch location, and remove the animation.
elementView.center = [touch locationInView:self.view];
[elementView.layer removeAllAnimations];
This should work. Then you can use the similar touchesMoved method to update the position during the drag.
Upvotes: 1