ringring demo

// 跳动的球球
    __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)