2012-02-10 2 views

답변

0


당신이 당신의 객체에 실제 마무리 포인트 값을 설정하는 것을 잊었다처럼이

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1.0]; 
CGRect frame=objectName.frame; 
frame.origin.x=frame.origin.x-20;//change the point according to you 
frame.origin.y=frame.origin.y-20;//change the point according to you 
objectName.frame=frame; 
[UIView commitAnimations]; 
+0

이 코드는 정상적으로 작동하지만 실제로는 코어 애니메이션을 사용하여 복잡한 애니메이션을 수행하려고합니다. 예를 들어, 사용자가 정의한 경로에서 객체를 이동합니다. –

+0

애니메이션이 끝난 후 애니메이션이 끝날 때마다 객체의 위치를 ​​변경해야 객체가 목적지 지점에 남아있게됩니다. – hchouhan02

2

이 보이는보십시오. CABasicAnimation으로 애니메이션 속성을 적절하게 설정합니다.

+1

내 코드 : CABasicAnimation * translateAnim = [CABasicAnimation animationWithKeyPath : @ "transform.translation.y"]; translateAnim.duration = 1.0; translateAnim.fromValue = [NSNumber numberWithFloat : 0.0f]; translateAnim.toValue = [NSNumber numberWithFloat : -100.f]; [레이어 addAnimation : translateAnim forKey : @ "이동"]; –