美文网首页
代码片段 分段动画

代码片段 分段动画

作者: 梓华 | 来源:发表于2019-10-29 10:08 被阅读0次
        CAKeyframeAnimation *animation1 = [CAKeyframeAnimation animationWithKeyPath:@"position"];
        animation1.duration = 1.6;
        animation1.repeatCount = CGFLOAT_MAX;
        animation1.calculationMode = kCAAnimationLinear;
        animation1.values = @[[NSValue valueWithCGPoint:CGPointMake(center.x + 40, center.y)],
                             [NSValue valueWithCGPoint:CGPointMake(center.x + 100, center.y)],
                             [NSValue valueWithCGPoint:CGPointMake(center.x + 100, center.y)],
                             [NSValue valueWithCGPoint:CGPointMake(center.x, center.y)]];
        animation1.keyTimes = @[@(0),@(0.4),@(1),@(1)];
        
        CAKeyframeAnimation *animation2 = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
        animation2.duration = 1.6;
        animation2.repeatCount = CGFLOAT_MAX;
        animation2.calculationMode = kCAAnimationLinear;
        animation2.values = @[@1, @0, @0];
        animation2.keyTimes = @[@0, @0.7, @1];
        
        [self.extraView1.layer addAnimation:animation1 forKey:@"extraView1_animation1"];
        [self.extraView2.layer addAnimation:animation1 forKey:@"extraView2_animation1"];
        [self.extraView1.layer addAnimation:animation2 forKey:@"extraView1_animation2"];
        [self.extraView2.layer addAnimation:animation2 forKey:@"extraView2_animation2"];
    

    相关文章

      网友评论

          本文标题:代码片段 分段动画

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