Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode custom segue - Opposite of Cover Vertical (top to bottom) - COMPLETE NEWBIE

Tags:

xcode

segue

I have been trying for some time to create a custom segue that does the opposite of the cover vertical (to create a from top to bottom effect animation).I had looked through other questions, google and youtube but cannot get it working.I am completely new to the classes etc. so any help in a step by step guide or video would be so good. I believe that this URL is trying to do something similar to what I want:

http://jrwren.wrenfam.com/blog/2012/02/01/storyboard-custom-segue-for-custom-pushviewcontroller-animation/ , I just cannot get it working.

If any of you know a way to create a segue that is a top to bottom version of the cover vertical segue could you please help me out?

like image 391
BrownEye Avatar asked Dec 29 '12 12:12

BrownEye


1 Answers

Well, you would want to create a subclass of UIStoryBoardSegue, like the walkthrough shows you, however under the Storyboard class' .m file(implementation) you would want the following code as your -(void)perform: method -

-(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:CGAffineTransformMakeTranslation(0, -sourceViewController.view.frame.size.height)];
[destinationViewController.view setAlpha:1.0];

[UIView animateWithDuration:0.75
                      delay:0.0
                    options:UIViewAnimationOptionTransitionFlipFromTop
                 animations:^{
                     [destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, 0)];
                     [destinationViewController.view setAlpha:1.0];
                 }
                 completion:^(BOOL finished){
                     [destinationViewController.view removeFromSuperview];
                     [sourceViewController presentViewController:destinationViewController animated:NO completion:nil];
                 }];}

Hopefully this is helpful.

like image 180
dmason82 Avatar answered Nov 16 '22 02:11

dmason82