在设置CABasicAnimation动画的同时执行代码(选择器)


CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
rotationAnimation.toValue = [NSNumber numberWithFloat: 2*M_PI];
rotationAnimation.duration = 1.0;
[self.layer addAnimation:rotationAnimation forKey:@"rotationAnimation1"];

我想在度为M_PI时执行代码,换句话说,我在UIView上有两个按钮,我想在旋转UIView时更改它们的标签,我不想让用户感觉到按钮在他面前发生了变化,所以最好的方法是在UIView旋转到一半时执行标签更改。

帮助我

rotationAnimation分为两步,每步旋转M_PI弧度。第一个动画完成后(即,从动画的代理animationDidStop:finished:函数开始(,开始第二个动画,同时更改标签。

或者您可以简单地在0.5秒后开始第二个动画。

最新更新