私は、CAReplicatorlayer、CATextLayer、および非常に基本的なアニメーションを使用して、クールなテキスト効果を作成しようとしています。画面の上部から文字がドロップされているように見せようとしています。その後、クールなレプリケーターが表示されなくなります。私はなんとかこの効果を行うことができましたが、完全ではありません。
これまでのところ、これは私が持っているものです:
CATextLayer *messageLayer = [CATextLayer layer];
[messageLayer setForegroundColor:[[UIColor blackColor] CGColor]];
[messageLayer setContentsScale:[[UIScreen mainScreen] scale]];
[messageLayer setFrame:CGRectMake(0, 0, 40, 40)];
[messageLayer setString:@"A"];
CAReplicatorLayer *replicatorX = [CAReplicatorLayer layer];
//Set the replicator's attributes
replicatorX.frame = CGRectMake(0, 0, 40, 40);
replicatorX.anchorPoint = CGPointMake(0,0);
replicatorX.position = CGPointMake(0, 0);
replicatorX.instanceCount = 9;
replicatorX.instanceDelay = 0.15;
replicatorX.instanceAlphaOffset = -0.1;
replicatorX.zPosition = 200;
replicatorX.anchorPointZ = -160;
[replicatorX addSublayer:messageLayer];
[self.view.layer addSublayer:replicatorX];
messageLayer.position = CGPointMake(40, 400);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.y"];
animation.fromValue = [NSNumber numberWithInt:0];;
animation.toValue = [NSNumber numberWithInt:400];
animation.duration = 3;
[messageLayer addAnimation:animation forKey:@"s"];
私には2つの問題があります:
- 複製されたレイヤーはエンドポイントから始まります。
- メインレイヤーが最後のアニメーションポイントに到達すると、アニメーションが停止し、複製されたレイヤーはアニメーションを終了できません。