CAReplicatorLayer *replicatorLayer = [[CAReplicatorLayer alloc] init];
replicatorLayer.frame=CGRectMake(10,100,30,30);
replicatorLayer.instanceCount=4;
replicatorLayer.instanceTransform =CATransform3DMakeTranslation(8, 0, 0);
replicatorLayer.instanceDelay=0.2;
replicatorLayer.masksToBounds=YES;
replicatorLayer.backgroundColor = [UIColor yellowColor].CGColor;
CALayer*layer = [CALayerlayer];
layer.frame=CGRectMake(0,30,2,30);
layer.backgroundColor = [UIColor redColor].CGColor;
[replicatorLayeraddSublayer:layer];
[self.view.layeraddSublayer:replicatorLayer];
CABasicAnimation *animation = [CABasicAnimation animation];
animation.keyPath=@"position.y";
animation.duration=0.5;
animation.toValue=@30;
animation.autoreverses=YES;
animation.repeatCount=MAXFLOAT;
[layeraddAnimation:animationforKey:nil];
网友评论