2012-01-27 2 views
0

toValue 프로세스가 완료된 후 어떻게 UIImageView transform.translation.x 애니메이션을 계속 진행할 수 있습니까? 예 : 버튼 1을 누르면 1에서 55로, 버튼 2를 55에서 110로 누릅니다. ... 단추 # 2의 위치에 있고 단추 # 5를 누른 다음 55 * 2에서 55 * 5까지를 클릭합니다.CABasicAnimation fromValue에서 계속

- (void)animateArrow{ 
CABasicAnimation *theAnimation; 


theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; 
theAnimation.duration=0.4; 
theAnimation.repeatCount=1; 
theAnimation.toValue=[NSNumber numberWithFloat:50]; 

[buttonArrow.layer setValue:theAnimation.toValue forKey:theAnimation.keyPath]; 
[buttonArrow.layer addAnimation:theAnimation forKey:@"transform.translation.x"]; 

}

답변

1
당신은 다음과 같은 배열에 애니메이션 경로를 따라 여러 지점을 제공에 대해 생각해야

:이 작품

CAKeyframeAnimation *downMoveAnimation; 
downMoveAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.y"]; 
downMoveAnimation.duration = 12; 
downMoveAnimation.repeatCount = 1; 
downMoveAnimation.values = [NSArray arrayWithObjects:   
          [NSNumber numberWithFloat:20], 
          [NSNumber numberWithFloat:220], 
          [NSNumber numberWithFloat:290], nil]; 
downMoveAnimation.keyTimes = [NSArray arrayWithObjects:  
           [NSNumber numberWithFloat:0], 
           [NSNumber numberWithFloat:0.5], 
           [NSNumber numberWithFloat:1.0], nil]; 

downMoveAnimation.timingFunctions = [NSArray arrayWithObjects: 
             [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn],  // from keyframe 1 to keyframe 2 
             [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], nil]; // from keyframe 2 to keyframe 3 

downMoveAnimation.removedOnCompletion = NO; 
downMoveAnimation.fillMode = kCAFillModeForwards; 

희망.

기본 애니메이션과 키 프레임 애니메이션의 주요 차이점은 키 프레임을 사용하면 경로상의 여러 지점을 지정할 수 있다는 것입니다.

+0

감사합니다. 매력 작품처럼 .. :) –

관련 문제