ios 音乐跳动动画-CAReplicatorLayer

来源:互联网 发布:电影人工智能观后感 编辑:程序博客网 时间:2024/05/18 23:12
- (void)viewDidLoad {    [super viewDidLoad];    self.view.backgroundColor = [UIColor grayColor];        CAReplicatorLayer *replicatorLayer = [[CAReplicatorLayer alloc] init];    replicatorLayer.frame = CGRectMake(0, 100, 375, 200);    replicatorLayer.instanceCount = 16;    replicatorLayer.instanceTransform  = CATransform3DMakeTranslation(20, 0, 0);    replicatorLayer.instanceDelay = 0.2;    replicatorLayer.masksToBounds = YES;    replicatorLayer.backgroundColor = [UIColor blackColor].CGColor;        CALayer *layer = [CALayer layer];    layer.frame = CGRectMake(14, 200, 10, 100);    layer.backgroundColor = [UIColor redColor].CGColor;    [replicatorLayer addSublayer:layer];    [self.view.layer addSublayer:replicatorLayer];        CABasicAnimation *animation = [CABasicAnimation animation];    animation.keyPath = @"position.y";    animation.duration = 0.5;    animation.fromValue = @200;    animation.toValue = @150;    animation.autoreverses = YES;    animation.repeatCount = MAXFLOAT;    [layer addAnimation:animation forKey:nil];    }

阅读全文
0 0
原创粉丝点击