1

私のアプリケーションは、iOSがデフォルトで提供する右側からではなく、左側からアニメーションをプッシュしたいアラビア語のテキストを表示しています。

ここに画像の説明を入力

ストーリーボードを使用しています。カスタム セグエを作成しました。 cocoacontrols
のすべてのオプションを確認しましたが、目的のオプションが見つかりませんでした。

次のようないくつかのオプションが見つかりました。

1) CATransition
2) アニメーション
3) ビュー コントローラ配列の維持 - これにより多くの混乱が生じます

以下のコードは完璧な効果をもたらしますが、以下に示すような黒いパッチは受け入れられません-

ここに画像の説明を入力

-(void)perform {


UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];


CATransition* transition = [CATransition animation];
transition.duration = .25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom




[sourceViewController.navigationController.view.layer addAnimation:transition
                                                            forKey:kCATransition];

[sourceViewController.navigationController pushViewController:destinationController animated:NO];

[destinationController.view setBackgroundColor:[UIColor whiteColor]];

}

以下のコードを実装すると、黒いパッチは表示されませんが、アニメーションは望ましくありません

  -(void)perform {

 UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
 UIViewController *destinationViewController = (UIViewController*)[self destinationViewController];



[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setTransform:CGAffineTransformMakeScale(0.5,0.5)];
[destinationViewController.view setAlpha:1.0];

[UIView animateWithDuration:0.5
                      delay:0.0
                    options:UIViewAnimationCurveEaseOut
                 animations:^{
                     [destinationViewController.view setTransform:CGAffineTransformMakeScale(1.0,1.0)];
                     [destinationViewController.view setAlpha:1.0];
                 }
                 completion:^(BOOL finished){
                     [destinationViewController.view removeFromSuperview];
                     [sourceViewController.navigationController pushViewController:destinationViewController animated:NO];
                 }];

   }

上記のコードを変更することにより -しかし、私は望ましい結果を得ていません

-(void)perform{

UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationViewController = (UIViewController*)[self   destinationViewController];



   [sourceViewController.view addSubview:destinationViewController.view];
   [destinationViewController.view setFrame:sourceViewController.view.window.frame];
   [destinationViewController.view setAlpha:1.0];

[UIView animateWithDuration:0.5
                      delay:0.0
                    options:UIViewAnimationCurveEaseOut
                 animations:^{

                     sourceViewController.view.frame =      CGRectMake(sourceViewController.view.frame.size.width*2, 0, sourceViewController.view.frame.size.width, sourceViewController.view.frame.size.height);



                 }
                 completion:^(BOOL finished){


                     [sourceViewController.navigationController pushViewController:destinationViewController animated:NO];
                 }];

}
4

2 に答える 2

1

以下のコードを appDelegate.m で使用 -applicationDidFinishLaunchingWithOptions

self.window.backgroundColor = [UIColor whitecolor];
于 2014-02-03T16:51:45.580 に答える
0

これは、乱雑な方法を使用して、View Controller のリストを操作する Swift のカスタム セグエです。のアニメーションですが、最終的には、一般的なポップを使用するため、iOS のスタイルが変更された場合など、コードを維持する必要がないため、これが必要なものを取得する最も簡単な方法でした。そのままにしておく必要があります。システムのデフォルトのポップと同じ..とにかく、コードに:

class ReversePushSegue : UIStoryboardSegue {

    override func perform() {
        let sourceViewController = self.sourceViewController as UIViewController
        let destinationViewController = self.destinationViewController as UIViewController

        var vcs : NSMutableArray = NSMutableArray(array: sourceViewController.navigationController.viewControllers)
        vcs.insertObject(destinationViewController, atIndex: vcs.count - 1)
        sourceViewController.navigationController.viewControllers = vcs

        sourceViewController.navigationController.popViewControllerAnimated(true)

    }

}

それが何をするか - それは最後から2番目としてdestinationViewControllerをリストに追加し、次にそれにポップします..

于 2014-08-24T14:49:10.177 に答える