关于实现心跳效果的动画

//核心动画
    CGFloat duration = 1.f;
    CGFloat height = 7.f;
    CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.y"];
    CGFloat currentTy = _callView.transform.ty;
    animation.duration = duration;
    animation.values = @[@(currentTy), @(currentTy + height/2), @(currentTy+height/2*2), @(currentTy+height/2*3), @(currentTy + height), @(currentTy+height/2*3), @(currentTy +height/2*2), @(currentTy + height/2), @(currentTy)];
    animation.keyTimes = @[ @(0), @(0.025), @(0.085), @(0.2), @(0.5), @(0.8), @(0.915), @(0.975), @(1) ];
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    animation.repeatCount = HUGE_VALF;
    [_callView.layer addAnimation:animation forKey:@"kViewShakerAnimationKey"];
````![2018-08-13 10_22_44.gif](https://upload-images.jianshu.io/upload_images/3840373-833005e0185d0bdf.gif?imageMogr2/auto-orient/strip)

你可能感兴趣的:(关于实现心跳效果的动画)