如何在帧动画播放结束或开始时检测CAKeyframeAnimation的值更改响应?

时间:2017-10-23 02:27:02

标签: ios calayer caanimation cakeyframeanimation

我创建了CAKeyFrameAnimation

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"bounds"];
CGRect rt1 = CGRectMake(0, 0, 0, self.height);
CGRect rt2 = CGRectMake(0, 0, self.width, self.height);
CGRect rt3 = CGRectMake(0, 0, self.width/3, self.height);
CGRect rt4 = CGRectMake(0, 0, self.width, self.height);

animation.values = @[[NSValue valueWithCGRect:rt1],
                     [NSValue valueWithCGRect:rt2],
                     [NSValue valueWithCGRect:rt3],
                     [NSValue valueWithCGRect:rt4]];
animation.keyTimes = @[@(0.0),
                       @(BaseTime/totalTime),
                       @((BaseTime + 0.1)/totalTime),
                       @((3*BaseTime + 0.1)/totalTime),
                       @(1.0)];
animation.repeatCount = 1;
animation.autoreverses = NO;
animation.duration = totalTime;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;

[_progressLayer addAnimation:animation forKey:@"ProgressAnimation"];

当其中一个边界帧动画结束或下一帧动画开始播放时,如何获得回调? 我需要检测更改的边界宽度,有什么方法可以响应它吗?

0 个答案:

没有答案