简体   繁体   中英

Custom segue in iOS

I am trying to make a custom seque where src falls down revealing dst. This is what I currently have. How can I make dst be behind src?

-(void)perform {
    UIViewController *src = [self sourceViewController];
    UIViewController *dst = [self destinationViewController];

    [UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationCurveEaseIn
                     animations:^{
                         [src.parentViewController.view setTransform:CGAffineTransformMakeTranslation(0, src.view.bounds.size.height)];
                     }
                     completion:nil];

    [src presentViewController:dst animated:NO completion:nil];

}

Rather than arranging your destination view controller be behind your source controller, why not try this instead: render your source view controller to an image view, add that image to your source controller, and then animate the image falling down.

This has a number of benefits: firstly, whatever you end up doing you may need to render your source view controller out to an image anyway for performance reasons. Secondly, it avoids having to mess around with the view controller hierarchy.

If that wasn't totally clear, here it is step by step:

  1. Render your source view controller out to a UIImageView
  2. Add that UIImageView to your destination view controller (so that it covers the destination view entirely)
  3. Remove your source view controller and add the destination controller - this should be seamless/invisible, since your destination controller is showing the rendered image you prepared earlier.
  4. Animate the UIImageView falling down to reveal the view content beneath it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM