我遇到與iOS CABasicAnimation
有關的問題。無論我做什麼,我都無法啓動方法animationDidStart:
和animationDidStop:finished:
。提前未調用的CAAnimation委託方法
- (void)start{
[self removeAllAnimations];
CABasicAnimation *pathAnimation = [self makeAnimationForKey:@"strokeEnd"];
[self addAnimation:pathAnimation forKey:@"strokeEnd"];
}
- (CABasicAnimation *)makeAnimationForKey:(NSString *)key {
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:key];
anim.fromValue = [NSNumber numberWithFloat:0.f];
anim.toValue = [NSNumber numberWithFloat:1.f];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
anim.duration = self.duration;
anim.delegate = self;
return anim;
}
- (void)animationDidStart:(CAAnimation *)anim{
NSLog(@"HERE START");
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
NSLog(@"HERE STOP");
}
任何提示或幫助將不勝感激,謝謝:我的類繼承CAShapeLayer
並執行它裏面的動畫!
記住層被克隆的動畫時,那麼你可能不會得到你想要使用像這樣的一個子類的效果。 – 2015-04-04 05:24:02
感謝提醒大衛,我一定會記住它。 – 2015-04-05 19:17:02
__請注意''CAAnimation''''delegate'是強大的,所以你可能需要將它設置爲'nil'來避免保留週期!__ – 2016-08-10 12:35:37