1

我正在尝试实现 SUBJ,但无法使目标转场出现在我的动画中。我想为视图更改制作动画,其中新的 segue 将取代旧的。目前我的执行方法如下所示:

- (void) perform {

UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;

[UIView animateWithDuration:2.0
                 animations:^{

                 //tried a lot of staff to make dst view to fall from top at the same time as current view falling to bottom but failed. 

                 src.view.transform=CGAffineTransformMakeTranslation(0, 480);
                 }
                 completion:^(BOOL finished){ 
                     [[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
                 }
    ];
}

任何想法如何添加到我的动画块从顶部出现的新视图?

非常感谢!

编辑:

- (void) perform {

    UIViewController *src = (UIViewController *) self.sourceViewController;
    UIViewController *dst = (UIViewController *) self.destinationViewController;

    src.view.transform = CGAffineTransformMakeTranslation(0, 0);
    dst.view.transform = CGAffineTransformMakeTranslation(0, -480);

    [UIView animateWithDuration:2.0
                 animations:^{
                         [src.view addSubview:dst.view];
                         src.view.transform = CGAffineTransformMakeTranslation(0, 460);

                     }
                     completion:^(BOOL finished){ 
                         [src presentModalViewController:dst animated:NO];
                     }
     ];

}

这就是我最后的做法。

4

1 回答 1

4

我不太明白你所说的新旧是什么意思,所以我假设新 = dst 和旧 = src。

- (void) perform {

   UIViewController *src = (UIViewController *) self.sourceViewController;
   UIViewController *dst = (UIViewController *) self.destinationViewController;

   src.view.transform = CGAffineTransformMakeTranslation(0, 0);
   dst.view.transform = CGAffineTransformMakeTranslation(0, -480);

   [UIView animateWithDuration:2.0
                 animations:^{
                     [src presentModalViewController:dst animated:NO];
                     src.view.transform = CGAffineTransformMakeTranslation(0, 480);
                     dst.view.transform = CGAffineTransformMakeTranslation(0, 0);
                 }
   ];
}

这应该这样做。

于 2012-04-05T19:25:51.517 回答