我正在制作 CABasicAnimation,问题是animationDidStop 委托方法没有被调用。我不知道为什么,但希望有人知道。
这是我的动画:
CABasicAnimation *theAnimation;
theAnimation = [CABasicAnimation animationWithKeyPath: @"transform.translation.x"];
theAnimation.duration = 54;
//theAnimation.repeatCount = 6;
theAnimation.autoreverses = YES;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat: (self.myImageView.frame.size.height / 5) + (self.view.frame.size.height - self.myImageView.center.x)];
theAnimation.toValue = [NSNumber numberWithFloat: 6.0 - (self.myImageView.frame.origin.y + self.myImageView.frame.size.height)];
//[self.myImageView.layer addAnimation:theAnimation forKey: @"animateLayer"];
[theAnimation setValue:@"Animation1" forKey:@"animateLayer"];
[[self.myImageView layer] addAnimation:theAnimation forKey:nil];
这也是我的animationDidStop方法:
- (void)animationDidStop:(CABasicAnimation *)theAnimation finished:(BOOL)flag {
NSString* value = [theAnimation valueForKey:@"animateLayer"];
if ([value isEqualToString:@"Animation1"])
{
[self themethod];
return;
}
if ([value isEqualToString:@"Animation2"])
{
[self themethod];
return;
}
}
有谁知道为什么会发生这种情况?
您需要设置委托来调用animationDidStop
.
theAnimation.delegate = class (self)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)