CABasicAnimation 从 fromValue 继续
在完成 toValue 过程后,我如何继续 UIImageView transform.translation.x 动画。例如:当按按钮#1:从 1 到 55,按按钮#2 从 55 到 110....并且如果它在按钮#2的位置,然后单击按钮#5,然后从55*2到55*5。
- (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"];
}
How can i continue a UIImageView transform.translation.x animation after it completed a toValue Process.for example:when press the button#1:from 1 to 55,press button#2 from 55 to 110....and if it at the position of button#2,and you click button#5,then from 55*2 to 55*5.
- (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"];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该考虑在数组中沿着动画路径提供多个点,如下所示:
希望这有效。
基本动画和关键帧动画之间的主要区别在于关键帧允许您指定路径上的多个点。
You should think about providing multiple points along the animation path in an array like this:
Hope this works.
The main difference between basic animation and key-frame animation is that Key-frame allows you to specify multiple points along the path.