0

pushViewController一連の画像を使用したアニメーションのカスタムアニメーションを作成したいと思います。

私はこれを私がcurrentViewController望む画像で覆われるところまで行ってきましたnextViewControllerが、アニメーション画像の順序を逆にしようとしたときに明らかにすることができるかどうかわかりません。

これまでのところ私は以下を持っています

- (IBAction)nextAction:(id)sender {

    UIImage* img1 = [UIImage imageNamed:@"image-1.png"]; 
    UIImage* img2 = [UIImage imageNamed:@"image-2.png"];
    UIImage* img3 = [UIImage imageNamed:@"image-3.png"];
    UIImage* img4 = [UIImage imageNamed:@"image-4.png"];
    UIImage* img5 = [UIImage imageNamed:@"image-5.png"];

    NSArray *animationImages = [NSArray arrayWithObjects:img1,img2,img3,img4,img5,nil];

    CALayer *myLayer = [CALayer layer];
    myLayer.bounds = CGRectMake(0.0, 0.0, 320.0, 480.0);
    myLayer.position =  self.view.center; //CGPointMake(0.0 ,0.0);
    CAKeyframeAnimation *animationSequence = [CAKeyframeAnimation animationWithKeyPath: @"contents"];
    animationSequence.calculationMode = kCAAnimationLinear;
    animationSequence.autoreverses = NO;
    animationSequence.duration = 0.4;
    animationSequence.delegate = self;
    animationSequence.repeatCount = 1; //HUGE_VALF;
    NSMutableArray *animationSequenceArray = [[NSMutableArray alloc] init];
    for (UIImage *image in animationImages) 
    {
        [animationSequenceArray addObject:(id)image.CGImage];
    }
    animationSequence.values = animationSequenceArray;
    [myLayer addAnimation:animationSequence forKey:@"contents"];    
    [self.view.layer addSublayer:myLayer];

}


- (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished {

    NextViewController *nextViewController;
    nextViewController = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil];
    nextViewController.title = @"next";

    [self.navigationController pushViewController:nextViewController animated:NO];
    [nextViewController release];

}

これIBAction nextActionは、ユーザーがボタンを押すと実行され、画像は現在のビューの上にアニメーション化されます。

私が達成したいのは、画像が上に表示された後、画像のnextViewController下を押してアニメーションを反転し、画像が表示されるようにnextViewControllerすることです。

これが理にかなっていることを願っています。写真を持っているのと同じように、写真の上にいくつかのカードを置き、カードを取り除くと別の写真が表示されます。

テオ

4

1 に答える 1

0

そのアニメーション レイヤーを現在の viewController に追加する代わりに、そのレイヤーを現在の keyWindow に直接追加します。これにより、現在のviewControllerが非表示になります。

[[[UIApplication sharedApplication] keyWindow] layer addSublayer:myLayer];

アニメーションの前半が完了したら (つまり、順方向の完全なアニメーションが完了したら)、アニメーション レイヤーを削除します。viewController を新しいものに置き換え、2 番目のアニメーション レイヤーを keyWindow に再度追加します。アニメーションの後半を開始します。それが完了したら、keyWindow からアニメーション レイヤーを削除します。

アプリケーションの構造によっては、アニメーション レイヤーのスーパービュー/スーパーレイヤーとして、追加の viewController の下に効果的に存在する rootViewController を使用することもできます。

[[[[UIApplication sharedApplication] rootViewController] view] layer addSublayer:myLayer];
于 2012-05-19T08:24:11.860 に答える