美文网首页
ringring demo

ringring demo

作者: 我是卖报滴小行家 | 来源:发表于2018-08-09 09:47 被阅读7次
    // 跳动的球球
        __block CAReplicatorLayer *layer = [CAReplicatorLayer layer];
        layer.frame = CGRectMake(50, 50, 200, 50);
        layer.backgroundColor = [UIColor lightGrayColor].CGColor;
        [self.view.layer addSublayer:layer];
        
        // 创建单个layer
        CALayer *bar = [CALayer layer];
        bar.backgroundColor = [UIColor whiteColor].CGColor;
        bar.bounds = CGRectMake(0, 0, 14, 14);
        bar.cornerRadius = 7;
        bar.position = CGPointMake(30, 35);
        bar.anchorPoint = CGPointMake(0.5, 0.5);
        [layer addSublayer:bar];
        
        // 添加动画
        CABasicAnimation *anim = [CABasicAnimation animation];
        anim.keyPath = @"position.y";//transform.scale.y  position.y
        anim.toValue = @(14);
        anim.autoreverses = YES;
        anim.repeatCount = MAXFLOAT;
        anim.duration = 0.5;
        [bar addAnimation:anim forKey:nil];
    
        // 复制
        layer.instanceCount = 3;
        layer.instanceTransform = CATransform3DMakeTranslation(25, 0, 0);
        layer.instanceDelay = 0.2;
        
    

    相关文章

      网友评论

          本文标题:ringring demo

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