美文网首页
向外扩散的圆形动画

向外扩散的圆形动画

作者: elephant0001 | 来源:发表于2019-04-24 11:24 被阅读0次

    -(void)addanimationwithView:(UIView *)circleView{    

    NSInteger pulsingCount = 5;    

    double animationDuration = 5;    

    CALayer *animationLayer = [CALayer layer];   

     for (int i = 0; i < pulsingCount; i++) {        

    CALayer * pulsingLayer = [CALayer layer];//        

    pulsingLayer.frame = CGRectMake(0, 0, circleView.frame.size.width, circleView.frame.size.height);       

     pulsingLayer.frame = CGRectMake(0, 0, YC_directionX(300), YC_directionX(300));//        

    pulsingLayer.frame = circleView.bounds;//        

    pulsingLayer.borderColor = NavColor.CGColor;        pulsingLayer.borderColor = [UIColor colorWithHexString:@"#CFEECF"].CGColor;        

    pulsingLayer.borderWidth = 15;//      

      pulsingLayer.cornerRadius = circleView.frame.size.width / 2;        

    pulsingLayer.cornerRadius = YC_directionX(150);                

    CAMediaTimingFunction * defaultCurve = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];                

    CAAnimationGroup * animationGroup = [CAAnimationGroup animation];        

    animationGroup.fillMode = kCAFillModeBackwards;        

    animationGroup.beginTime = CACurrentMediaTime() + (double)i * animationDuration / (double)pulsingCount;        

    animationGroup.duration = animationDuration;        

    animationGroup.repeatCount = HUGE;        

    animationGroup.timingFunction = defaultCurve;        


    animationGroup.removedOnCompletion = false;                


    CABasicAnimation * scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];        

    scaleAnimation.fromValue = @1.0;        

    scaleAnimation.toValue = @2.2;                

    CAKeyframeAnimation * opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];        

    opacityAnimation.values = @[@1, @0.9, @0.8, @0.7, @0.6, @0.5, @0.4, @0.3, @0.2, @0.1, @0];        

    opacityAnimation.keyTimes = @[@0, @0.1, @0.2, @0.3, @0.4, @0.5, @0.6, @0.7, @0.8, @0.9, @1];                

    animationGroup.animations = @[scaleAnimation, opacityAnimation];  

         

     [pulsingLayer addAnimation:animationGroup forKey:@"plulsing"];        

    [animationLayer addSublayer:pulsingLayer];    

    }    

    [circleView.layer addSublayer:animationLayer];

    }

    相关文章

      网友评论

          本文标题:向外扩散的圆形动画

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