2012-11-05 24 views
0

我使用UIPanGestureRecognizer沿着用戶繪製的路徑移動一個對象。但是這個對象是動畫,我需要在動畫過程中與它進行交互。可能嗎?我已經嘗試使用UIViewAnimationOptionAllowUserInteraction但沒有結果。iOS - UIPanGestureRecognizer:在動畫中拖動

+0

http://stackoverflow.com/a/5572717/1059705&http://stackoverflow.com/q/8340329/1059705這可能會幫助你 – Bala

+0

http://developer.apple .com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#// apple_ref/doc/c_ref/UIViewAnimationOptionAllowUserInteraction – Bala

回答

0

是的,這是可能的。但是我會使用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. 
+0

我該怎麼做?所以,現在我使用UIView動畫,並移動了對象框架,但是使用CABasicAnimation,我該如何做同樣的事情? –

+0

所以物體在移動,當用戶點擊它時,它應該停止移動並遵循他的平移手勢?那是你要的嗎? – Masa

+0

是的,是我想要的! @iMasa –