【问题标题】:Animating the trajectory change using core animation使用核心动画对轨迹变化进行动画处理
【发布时间】:2015-10-12 06:00:01
【问题描述】:

我有基本的 UILabel,它使用 CACAKeyframeAnimation 沿着一个完整的圆圈制作动画:

CGMutablePathRef path = CGPathCreateMutable();
CGPathAddArc(path,nil, center.x,center.y, radius , DEGREES_TO_RADIANS(from_degree), DEGREES_TO_RADIANS((360+from_degree)), NO);

CAKeyframeAnimation *theAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];

theAnimation.path = path;
CGPathRelease(path);

// set the animation properties
theAnimation.duration = duration;
theAnimation.removedOnCompletion = NO;
theAnimation.fillMode = kCAFillModeBoth;
theAnimation.repeatCount = INFINITY;
theAnimation.calculationMode = kCAAnimationPaced;

[label.layer addAnimation:theAnimation forKey:@"position"];

有没有办法为圆弧的半径变化设置动画并将该变化传播到沿路径移动的标签?

【问题讨论】:

    标签: ios objective-c core-animation caanimation


    【解决方案1】:
     CGPathMoveToPoint(thePath, NULL, 100.f, 100.f);
     CGPathAddLineToPoint(thePath, NULL, 200.f, 100.f);
     CGPathAddArc(thePath, NULL, 100.f, 100.f, 100.f, 0.f, (360* M_PI)/180, NO);
     CGPathCloseSubpath(thePath);
    

    你可以用这个:)

    【讨论】:

    • 你能解释一下这如何回答我的问题吗?我已经可以改变路径了。我想要路径之间的过渡。
    【解决方案2】:
     CGMutablePathRef path = CGPathCreateMutable();
        CGPathAddArc(path, NULL, 100.f, 100.f, 100.f, 0.f, (360* M_PI)/180, NO);
    
    
        CAKeyframeAnimation *theAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    
        theAnimation.path = path;
        CGPathRelease(path);
    
        // set the animation properties
        theAnimation.duration = 3.0;
        theAnimation.removedOnCompletion = NO;
        theAnimation.fillMode = kCAFillModeBoth;
        theAnimation.repeatCount = INFINITY;
        theAnimation.calculationMode = kCAAnimationPaced;
    
        [self.lblTest.layer addAnimation:theAnimation forKey:@"position"];
    

    试试这个..它会帮助你:)

    【讨论】:

    • 这是我在我的问题中输入的确切代码,我在问如何动画路径的变化。如果我用不同的圈子第二次杀死这个函数,我想要一个过渡
    • 这是我已经在使用的,你根本没有得到问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-13
    • 2018-04-09
    • 1970-01-01
    相关资源
    最近更新 更多