ios CAReplicatorLayer使用

这里写图片描述

    //     Do any additional setup after loading the view.
    CALayer * layer = [CALayer layer];
    layer.bounds = CGRectMake(0, 0, 30, 30);
    layer.position = CGPointMake(self.view.center.x - 50, self.view.center.y - 50);
    layer.backgroundColor = [UIColor redColor].CGColor;
    layer.cornerRadius = 15;
    [self.view.layer addSublayer:layer];

//    return;
    CABasicAnimation * animation1 = [CABasicAnimation animationWithKeyPath:@"opacity"];
    animation1.fromValue = @(0);
    animation1.toValue = @(1);
    animation1.duration = 1.5;
//        animation1.autoreverses = YES;

    CABasicAnimation * animation2 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    animation2.toValue = @(1.5);
    animation2.fromValue = @(0.5);
    animation2.duration = 1.5;
//        animation2.autoreverses = YES;

    CAAnimationGroup * ani = [CAAnimationGroup animation];
    ani.animations = @[animation1,animation2];
    ani.duration = 1.5;
    ani.repeatCount = MAXFLOAT;
    ani.autoreverses = YES;

    [layer addAnimation:ani forKey:nil];

    CAReplicatorLayer * rec = [CAReplicatorLayer layer];
    [rec addSublayer:layer];
    rec.instanceCount = 3;
    rec.instanceDelay = 0.5;
    rec.instanceTransform = CATransform3DMakeTranslation(50, 0, 0);
    [self.view.layer addSublayer:rec];

    CAReplicatorLayer * rec2 = [CAReplicatorLayer layer];
    [rec2 addSublayer:rec];
    rec2.instanceCount = 3;
    rec2.instanceDelay = 0.5;
    rec2.instanceTransform = CATransform3DMakeTranslation(0, 50, 0);
    [self.view.layer addSublayer:rec2];

博客:
http://www.jianshu.com/p/dedc44fe8e35

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值