Pergunta

I am trying to implement SUBJ but can't make destination segue appear in my animation. I want to make animation for view change where new segue will displace old one. Currently my perform method looks like this:

- (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];
                 }
    ];
}

Any ideas how can I add to my animation block new view appearing from top?

Many thanks!

EDIT:

- (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];
                     }
     ];

}

Thats how I did it in the end.

Foi útil?

Solução

I don't quite get what you mean by new and old so i assume new = dst and old = 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);
                 }
   ];
}

This should do it.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top