弄了个简单地动画,就是三个点的加载动画,在普通的控制器上显示正常,但是在模态出来的控制器上就无效了,求助。。。代码如下
CAReplicatorLayer *replicatorLayer = [CAReplicatorLayer layer];
replicatorLayer.bounds = CGRectMake(0, 0, 80, 100);
replicatorLayer.position = CGPointMake(CXScreenW * 0.5, CXScreenH * 0.5);
replicatorLayer.backgroundColor = [UIColor redColor].CGColor;
[self.layer addSublayer:replicatorLayer];
//添加一个点
CALayer *dotLayer = [CALayer layer];
dotLayer.bounds = CGRectMake(0, 0, 12, 12);
dotLayer.position = CGPointMake(15, replicatorLayer.frame.size.height/2);
dotLayer.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.2].CGColor;
dotLayer.cornerRadius = 7.5;
[replicatorLayer addSublayer:dotLayer];
//设置3个点
replicatorLayer.instanceCount = 3;
replicatorLayer.instanceTransform = CATransform3DMakeTranslation(replicatorLayer.frame.size.width/3, 0, 0);
//添加动画
CABasicAnimation *animation = [CABasicAnimation animation];
animation.keyPath = @"transform.scale";
animation.duration = 1.3;
animation.fromValue = @1;
animation.toValue = @0;
animation.repeatCount = MAXFLOAT;
[dotLayer addAnimation:animation forKey:nil];
replicatorLayer.instanceDelay = 1.0/3;
dotLayer.transform = CATransform3DMakeScale(0, 0, 0);