1

私はページカーリング効果を使用しています。ボタンをクリックすると、ページを通過できました(つまり、UIView間)。次のコードは同じものを示しています。

UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.5];  
    if ([sender tag] == 1) {
        [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:placeholder cache:YES];
    }
    else {
        [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:placeholder cache:YES];
    }
    if (view1OnTop) {
        [view1 removeFromSuperview];
        [placeholder addSubview:view2];
    }
    else {
        [view2 removeFromSuperview];
        [placeholder addSubview:view1];
    }
    [UIView commitAnimations];

    view1OnTop = !view1OnTop;

これで私はUIView間でカールすることができましたが、私の質問は、2つ以上のクラス間でこの種の遷移を適用できるでしょうか?前もって感謝します

4

1 に答える 1

6

すべてがアニメートできるわけではありません。UIKitの一部のみです。したがって、のサブクラスをアニメーション化できるかどうかを尋ねる場合は、NSObjectアニメーション化できません。UIViewのサブクラスをアニメーション化できるかどうかを尋ねる場合、答えは「はい」になります。それらは異なるサブクラスにすることもできます。これは可能ですが、それが正しい結果をもたらすという意味ではありません。彼らはかなり奇妙に見えるかもしれません。あなたはそれをしたくないかもしれません。

レイヤーもアニメート可能です。

ただし、それはすべて、クラスの意味によって異なります。

新しいViewControllerへのアニメーション

ビューコントローラ間を移動する方法を変更したい場合は、transitionWithView:duration:..のクラスメソッドを使用できますUIView。例、

SecondViewController * viewController = [[[SecondViewController alloc] initWithNibName:nil bundle:nil] autorelease];
[UIView transitionWithView:self.view.window
                  duration:1.0f
                   options:UIViewAnimationOptionTransitionCurlUp
                animations:^{
                    [self.navigationController pushViewController:viewController animated:NO];
                }
                completion:NULL];

これは、新しいViewControllerを押すときにカールアップトランジションを使用します。

4.0より古いバージョンのiOSの場合

ブロックベースのアニメーションAPIをサポートしていないため、これを行う必要があります。

[UIView beginAnimations:@"Curl up" context:NULL];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view.window cache:YES];

[self.navigationController pushViewController:viewController animated:NO];

[UIView commitAnimations];
于 2011-06-23T11:45:59.613 に答える