サンプルコードはhereです。暗黙的なプロパティアニメーションはCAReplicatorLayerでは機能しませんか?
明示的なプロパティのアニメーションを暗黙のプロパティのアニメーションに置き換えると、アニメーションが壊れます。
明示的なアニメーション:
-(void)animate:(id)sender {
...
//Transform Animation
animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.fromValue = [NSValue valueWithCATransform3D: CATransform3DIdentity];
animation.toValue = [NSValue valueWithCATransform3D: t];
animation.duration = 1.0;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeBoth;
[subLayer addAnimation:animation forKey:@"transform"];
//Opacity Animation
animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.fromValue = [NSNumber numberWithFloat:1.0];
animation.toValue = [NSNumber numberWithFloat:0.0];
animation.duration = 1.0;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeBoth;
[subLayer addAnimation:animation forKey:@"opacity"];
...
}
-(void)reset:(id)sender {
...
//Transform Animation
animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.fromValue = [NSValue valueWithCATransform3D: t];
animation.toValue = [NSValue valueWithCATransform3D: CATransform3DIdentity];
animation.duration = 1.0;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeBoth;
[subLayer addAnimation:animation forKey:@"transform"];
//Opacity Animation
animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.fromValue = [NSNumber numberWithFloat:0.0];
animation.toValue = [NSNumber numberWithFloat:1.0];
animation.duration = 1.0;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeBoth;
[subLayer addAnimation:animation forKey:@"opacity"];
...
}
暗黙のアニメーション:
-(void)animate:(id)sender {
...
//Transform Animation
[CATransaction setAnimationDuration:1];
subLayer.transform = t;
//Opacity Animation
[CATransaction setAnimationDuration:1];
subLayer.opacity = 0;
...
}
-(void)reset:(id)sender {
...
//Transform Animation
[CATransaction setAnimationDuration:1];
subLayer.transform = CATransform3DIdentity;
//Opacity Animation
[CATransaction setAnimationDuration:1];
subLayer.opacity = 1;
...
}
なぜ?
明らかに、私は暗黙のトランザクションを使用しています。 – an0
明らかに、私は間違っていましたが、ヒントを見つけましたが、手元にあるOSXのb/cをテストできませんでした。明らかに、そうでなければ聞いていない答えb/cをあなたは知らない。今私はもう少し調べて、私のマシンで働く答えを見つけました。 –
BTrans CATransaction begin/commitアニメーションを作成せずにレイヤーに追加する限り、暗黙的なアニメーションである限り、アニメーションを明示的にしません。明らかに、私は追加する必要があります:-) –