使用iPhone CALayer,我想要一个旋转动画用于我的精神图层,但我也想要一个动画结束的回调,热门这样做?

我想也许我应该使用CABasicAnimation,但我不知道如何使用CABasicAnimation进行旋转,任何想法?

由于

有帮助吗?

解决方案

如果为CAAnimation设置委托,则可以添加回调方法:

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag

动画完成后调用它。根据以下链接查找通过CGAffineTransform转换矩阵旋转动画的示例:

http://iphonedevelopment.blogspot.com/2008/10/demystifying- cgaffinetransform.html

其他提示

顺便说一下,你也可以通过在下面的代码块中包含调用旋转UIView来为UIView动画做同样的回调

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(rotationAnimationHasFinished:finished:context:)];
// Rotate the view here
[UIView commitAnimations];

然后定义委托方法

- (void)rotationAnimationHasFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context;
{
// Handle the completion of the animation
}
在您的委托中

,它将在动画完成后执行您需要的任何操作。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top