在CABasicAnimation结束时反弹

时间:2017-01-17 19:07:46

标签: ios objective-c cabasicanimation

设置动画:

CABasicAnimation *noteAnimation = [CABasicAnimation animation];
noteAnimation.keyPath = @"position.x";
noteAnimation.byValue = [NSNumber numberWithFloat:CGRectGetWidth(self.view.frame) - 50];
noteAnimation.duration = 1.f;
noteAnimation.fillMode = kCAFillModeBoth;
noteAnimation.removedOnCompletion = NO;
noteAnimation.autoreverses = YES;
noteAnimation.repeatCount = HUGE;
noteAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[self.greenSquareView.layer addAnimation:noteAnimation forKey:@"noteAnimation"];

暂停我使用的动作动画:

CFTimeInterval pausedTime = [view.layer convertTime:CACurrentMediaTime() fromLayer:nil];
view.layer.speed = 0.0;
view.layer.timeOffset = pausedTime;

但在这种情况下,视图会因弹跳而停止。

BitBucket上的完整项目。

enter image description here

0 个答案:

没有答案