iOS电流充电流动 动画

UIView *layerView = [[UIView alloc] initWithFrame:CGRectMake(20,150,[UIScreen mainScreen].bounds.size.width-40,200)];

[self.viewaddSubview:layerView];

    //绘制心电图背景

    CAShapeLayer*lineShapeLayer = [CAShapeLayerlayer];

    lineShapeLayer.frame=CGRectMake(0,0,600,300);

    lineShapeLayer.path= [selfbezierPath].CGPath;

    lineShapeLayer.fillColor= [UIColorclearColor].CGColor;

    lineShapeLayer.strokeColor= [UIColorwhiteColor].CGColor;

    lineShapeLayer.lineWidth=2;

    lineShapeLayer.opacity=0.5;

    lineShapeLayer.position= layerView.center;

    lineShapeLayer.transform=CATransform3DMakeScale(0.9,0.9,1.0f);

    [layerView.layeraddSublayer:lineShapeLayer];

//流动的layer

    CAShapeLayer*scrollShapeLayer = [CAShapeLayerlayer];

    scrollShapeLayer.frame=CGRectMake(0,0,600,300);

    scrollShapeLayer.position= layerView.center;

    scrollShapeLayer.path= [selfbezierPath].CGPath;

    scrollShapeLayer.strokeEnd=0.f;

    scrollShapeLayer.lineWidth=3;

    scrollShapeLayer.fillColor= [UIColorclearColor].CGColor;

    scrollShapeLayer.strokeColor= [UIColorgreenColor].CGColor;

    scrollShapeLayer.shadowColor= [UIColorgreenColor].CGColor;

    scrollShapeLayer.shadowRadius=4;

    scrollShapeLayer.shadowOpacity=1;

    scrollShapeLayer.lineCap=kCALineCapRound;

    scrollShapeLayer.transform=CATransform3DMakeScale(0.9,0.9,1.0f);

    [layerView.layeraddSublayer:scrollShapeLayer];


    CABasicAnimation*strokeStartAnimation = [CABasicAnimationanimationWithKeyPath:@"strokeStart"];

    strokeStartAnimation.fromValue=@0;

    strokeStartAnimation.toValue=@(0.95);


    CABasicAnimation *strokeEndAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];

    strokeEndAnimation.fromValue=@(0.05);

    strokeEndAnimation.toValue=@(1);


    CAAnimationGroup *group = [CAAnimationGroup animation];

    group.duration=8.f;

    group.repeatCount=MAXFLOAT;

    group.autoreverses=NO;///来回循环

    group.animations=@[strokeStartAnimation, strokeEndAnimation];


    [scrollShapeLayeraddAnimation:groupforKey:nil];

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容