美文网首页
旋转小图动画

旋转小图动画

作者: 萧城x | 来源:发表于2015-11-01 01:16 被阅读97次

    <pre><code>///点击一个 调用3次的 颜色 下拉动画 旋转小图图标

    #pragma mark - animation

    - (void)animateIndicator:(CAShapeLayer *)indicator Forward:(BOOL)forward complete:(void(^)())complete

    {

    [CATransaction begin];

    [CATransaction setAnimationDuration:0.25];

    [CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithControlPoints:0.4 :0.0 :0.2 :1.0]];

    CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];

    anim.values = forward ? @[ @0, @(M_PI) ] : @[ @(M_PI), @0 ];

    if (!anim.removedOnCompletion) {

    [indicator addAnimation:anim forKey:anim.keyPath];

    } else {

    [indicator addAnimation:anim andValue:anim.values.lastObject forKeyPath:anim.keyPath];

    }

    [CATransaction commit];

    indicator.fillColor = forward ? _tableView.tintColor.CGColor : _menuColor.CGColor;

    complete();

    }</code></pre>

    相关文章

      网友评论

          本文标题:旋转小图动画

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