2011-06-28 11 views
2

サンプルコードは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;  
    ... 
} 

なぜ?

答えて

-2

CALayerのデリゲートを、viewコントローラが適切な時刻(nitWithNibName:bundle:、awakeFromNib、viewDidLoad、およびviewWillAppear:animatedのいずれもない)で表示するものと異なるものに設定する必要があります。ここをクリックしてください:Does iPhone OS support implicit animation?

私のマシンでは、タッチでアニメーションを呼び出すことが非常にうまくいきました。

+0

明らかに、私は暗黙のトランザクションを使用しています。 – an0

+0

明らかに、私は間違っていましたが、ヒントを見つけましたが、手元にあるOSXのb/cをテストできませんでした。明らかに、そうでなければ聞いていない答えb/cをあなたは知らない。今私はもう少し調べて、私のマシンで働く答えを見つけました。 –

+0

BTrans CATransaction begin/commitアニメーションを作成せずにレイヤーに追加する限り、暗黙的なアニメーションである限り、アニメーションを明示的にしません。明らかに、私は追加する必要があります:-) –

1

暗黙のアニメーションを使用する場合、CATrasactionを使用する必要はありません。 uikitがUIViewのルートレイヤであるレイヤの暗黙的なアニメーションを無効にするように注意してください

+0

[CATransaction begin]; [CATransaction setValue:[NSNumber numberWithFloat:10.0f] forKey:kCATransactionAnimationDuration]; theLayer.zPosition = 200.0; theLayer.opacity = 0.0; [CATransaction commit]; – wihing

関連する問題