Skip to content

Instantly share code, notes, and snippets.

@ljanzik
Created May 30, 2012 09:54
Show Gist options
  • Save ljanzik/2835266 to your computer and use it in GitHub Desktop.
Save ljanzik/2835266 to your computer and use it in GitHub Desktop.
Implement Custom Segue To Use Own Animation
#import <UIKit/UIKit.h>
@interface MySegueWithCustomAnimation : UIStoryboardSegue
@end
#import "MySegueWithCustomAnimation.h"
@implementation MySegueWithCustomAnimation
-(void)perform{
UIViewController *destination = [self destinationViewController];
UIViewController *source = [self sourceViewController];
[destination viewWillAppear:NO];
[destination viewDidAppear:NO];
//[source retain]; only if ARC is not used
[source.view addSubview:destination.view];
CGRect original = destination.view.frame;
destination.view.frame = CGRectMake(destination.view.frame.origin.x+destination.view.frame.size.width, 0-destination.view.frame.size.height, destination.view.frame.size.width, destination.view.frame.size.height);
[UIView beginAnimations:nil context:nil];
destination.view.frame = CGRectMake(original.origin.x, original.origin.y, original.size.height, original.size.width);
[UIView commitAnimations];
[self performSelector:@selector(animationDone:) withObject:destination afterDelay:0.2f];
}
- (void)animationDone:(id)vc{
UIViewController *destination = (UIViewController*)vc;
UINavigationController *navController = [[self sourceViewController] navigationController];
[navController pushViewController:destination animated:NO];
//[[self sourceViewController] release]; only if ARC is not used
}
@end
@alexisbronchart
Copy link

Nope he didn't. This is a custom push segue. And by the way presentModalViewController:animated: is deprecated, if you want to make a custom modal segue use presentViewController:animated:completion: :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment