美文网首页
关于实现心跳效果的动画

关于实现心跳效果的动画

作者: 海笙樾 | 来源:发表于2018-08-13 10:23 被阅读0次
    //核心动画
        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://img.haomeiwen.com/i3840373/833005e0185d0bdf.gif?imageMogr2/auto-orient/strip)
    

    相关文章

      网友评论

          本文标题:关于实现心跳效果的动画

          本文链接:https://www.haomeiwen.com/subject/oaeybftx.html