ios音量振动条

@property (nonatomic,strong) CAReplicatorLayer *replicatorLayer;

@property (nonatomic,strong) CALayer *layer;

@property (nonatomic,strong) CABasicAnimation *basicAnimation;


@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    

    [self.view.layer addSublayer:self.replicatorLayer];

    [self.replicatorLayer addSublayer:self.layer];

    [self.layer addAnimation:self.basicAnimation forKey:nil];

}



- (CALayer *)layer

{

    if (_layer == nil) {

        _layer = [CALayer layer];

        _layer.backgroundColor = [UIColor greenColor].CGColor;

        _layer.bounds = CGRectMake(0, 0, 30, 100);

        _layer.position = CGPointMake(15, 200);

        _layer.anchorPoint = CGPointMake(0.5, 1);

    }

    return _layer;

}


- (CAReplicatorLayer *)replicatorLayer

{

    if (_replicatorLayer == nil) {

        _replicatorLayer = [CAReplicatorLayer layer];

        _replicatorLayer.frame = CGRectMake(50, 50, 200, 200);

        _replicatorLayer.backgroundColor = [UIColor blueColor].CGColor;

        // 设置4个子层,3个复制层

        _replicatorLayer.instanceCount = 4;

        // 设置复制子层的相对位置,每个x轴相差40

        _replicatorLayer.instanceTransform = CATransform3DMakeTranslation(40, 0, 0);

        // 设置复制子层的延迟动画时长

        _replicatorLayer.instanceDelay = 0.3;

    }

    return _replicatorLayer;

}


- (CABasicAnimation *)basicAnimation

{

    if (_basicAnimation == nil) {

        _basicAnimation = [CABasicAnimation animation];

        

        _basicAnimation.keyPath = @"transform.scale.y";

        _basicAnimation.toValue = @(0.1);

        _basicAnimation.autoreverses = YES;

        _basicAnimation.repeatCount = MAXFLOAT;


    }

    return _basicAnimation;

}

@end



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值