像这样的代码:我在我的视图控制器中存储了 3 个动画,但是当 - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag 被调用时,我发现动画的地址与它们中的任何一个都不相同,为什么?
- (void) redoAni
{
circleHalfCaloryMask.alpha = 1;
circleHalfTimeMask.alpha = 1;
circleHalfStopWatchMask.alpha = 1;
//[circleHalfCalory removeFromSuperview];
//circleHalfCalory.alpha = 0;
[circleHalfCaloryMask.layer addAnimation:rotate3 forKey:@"rotate3"];
[circleHalfStopWatchMask.layer addAnimation:rotate2 forKey:@"rotate2"];
[circleHalfTimeMask.layer addAnimation:rotate1 forKey:@"rotate1"];
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
if (anim == rotate1)
{
circleHalfTimeMask.alpha = 0;
}
else if (anim == rotate2)
{
circleHalfStopWatchMask.alpha = 0;
}
else if (anim == rotate3)
{
circleHalfCaloryMask.alpha = 0;
}
else
{
}
}
在 gdb 中:
rotate1 CABasicAnimation * 0x07297280
rotate2 CABasicAnimation * 0x072899a0
rotate3 CABasicAnimation * 0x07297d40
anim CABasicAnimation * 0x07285010