2012-01-13 2 views
0

보기를 이동하는 데이 코드가 있습니다.CAAnimation : 애니메이션 후 재설정 안 함

CABasicAnimation *theAnimation; 
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; 
theAnimation.duration=1; 
theAnimation.repeatCount=1; 
theAnimation.autoreverses=NO; 
theAnimation.fromValue=[NSNumber numberWithFloat:0]; 
theAnimation.toValue=[NSNumber numberWithFloat:-60]; 
[view.layer addAnimation:theAnimation forKey:@"animateLayer"]; 

문제는 다음과 같습니다. 애니메이션의 완료 후에 뷰의 실제 좌표가 재설정됩니다. 애니메이션이 끝난 후 뷰가 새 좌표에 남아있을 수 있습니까?

감사합니다.

답변

0

속성을 애니메이션화하는 애니메이션을 첨부하는 것 외에도 실제로 속성을 최종 값으로 설정해야합니다. 미친, 그렇지? 애니메이션을 추가하기 전에 다음을 시도하십시오.

[view.layer setValue:[NSNumber numberWithFloat:-60] forKey:@"transform.translation.x"]; 

WWDC 2011 비디오 "Core Animation Essentials"를 시청하는 것이 좋습니다. 이를 설명하고 Core Animation을 사용하는 모든 사람들에게 유용한 정보를 많이 제공합니다. 여기에서 찾으실 수 있습니다 : https://developer.apple.com/videos/wwdc/2011/

+0

감사합니다. 다른 대답을 찾았습니다 : [theAnimation setFillMode : kCAFillModeForwards]; 그럼 잘 작동합니다. 링크를 가져 주셔서 감사합니다. – user688262

관련 문제