저는 UIPanGestureRecognizer를 사용하여 사용자가 그린 경로를 따라 객체를 이동합니다. 그러나이 객체는 애니메이션을 적용하고 있으며 애니메이션 작업 중에이 객체와 상호 작용해야합니다. 가능한가? 이미 UIViewAnimationOptionAllowUserInteraction
을 사용하려고하지만 결과는 없습니다.iOS - UIPanGestureRecognizer : 애니메이션 도중 끌기
답변
예 가능합니다. 그러나 CABasicAnimation
을 사용하여 객체에 애니메이션을 적용하고 UIView animationWith...
을 사용하지 말고 UIPanGestureRecognizer
을 객체에 추가합니다. 그래서 몇 가지 예제 코드 :
// Configure the animation and add it to the layer.
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"];
anim.fromValue = ...
anim.duration = ...
[view.layer addAnimation:anim forKey:@"some key"];
// Then add the UIPanGestureRecognizer to that view.
어떻게하면됩니까? 이제는 UIView 애니메이션을 사용하고 객체 프레임을 이동하지만 CABasicAnimation을 사용하면 어떻게 동일한 작업을 수행 할 수 있습니까? –
그래서 물체가 움직이며 사용자가 그것을 두 드렸을 때 움직이지 않고 그의 팬 제스처를 따라야합니까? 너가 원하는게 그거야? – Masa
그래, 그게 내가 원하는거야? @iMasa –
http://stackoverflow.com/a/5572717/1059705 & http://stackoverflow.com/q/8340329/1059705이 당신에게 – Bala
도움이 될 수 http://developer.apple .com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html # // apple_ref/doc/c_ref/UIViewAnimationOptionAllowUserInteraction – Bala