- (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];
}
ios 音乐跳动动画-CAReplicatorLayer
最新推荐文章于 2024-06-25 09:49:40 发布