핵심 애니메이션을 사용하여 UiView를 적절히 애니메이트하는 데 약간의 문제가 있습니다.코어 애니메이션을 사용하여 애니메이션에 애니메이션을 적용 하시겠습니까?
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"position"];
[animation setFromValue:[NSValue valueWithCGPoint:self.view.layer.position]];
[animation setToValue:[NSValue valueWithCGPoint:CGPointMake(250, self.view.layer.position.y)]]; //I want to move my UIView 250 pts to the right
[animation setDuration:1];
[animation setDelegate:self]; //where self is the view controller of the view I want to animate
[animation setRemovedOnCompletion:NO];
[self.view.layer addAnimation:animation forKey:@"toggleMenu"]; //where self.view returns the view I want to animate
나는 또한 다음 대리자 메서드를 구현 한 :
-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
if(flag)
[self.view.layer setTransform:CATransform3DMakeTranslation(250, 0, 0)]; //set layer to its final position
}
나는 그것이 그렇게 UIView의 오른쪽으로 250 포인트를 이동하는 것을 만들려고 노력하고 있어요 여기 내 코드입니다. 그러나 애니메이션이 트리거되면 내보기가 움직이기 시작하지만 애니메이션이보기가 250 포인트 오른쪽으로 이동하기 전에 애니메이션이 종료 된 것처럼 보이기 때문에 UIView의 '텔레포트'가 최종 위치로 이동합니다. 이 문제의 원인을 파악할 수 없습니다.
나는 또한 UIView 메서드 +(void)animateWithDuration:animations:
을 사용하려고 시도했으며이 방법은 완벽하게 작동합니다. 그러나 미묘한 '바운스 (bounce)'효과를 얻으 려 노력하고 있으며 다중 콜백을 사용하는 대신 setTimingFunction:functionWithControlPoints:
메서드를 사용하여 훨씬 성취 할 수 있습니다.
모든 도움과 제안을 부탁드립니다.
바운스의 경우 키 프레임 애니메이션을 사용할 수 있습니다. – nielsbot