Skip to content

Instantly share code, notes, and snippets.

@spotlessicode
Created November 12, 2014 14:44
Show Gist options
  • Save spotlessicode/cc04d2e5893551d62ed0 to your computer and use it in GitHub Desktop.
Save spotlessicode/cc04d2e5893551d62ed0 to your computer and use it in GitHub Desktop.
#import "MyCustomUnwindSegue.h"
@implementation MyCustomUnwindSegue
- (void)perform
{
UIView *sourceView = ((UIViewController *)self.sourceViewController).view;
UIView *destinationView = ((UIViewController *)self.destinationViewController).view;
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
destinationView.center = CGPointMake(sourceView.center.x, sourceView.center.y + destinationView.center.y);
[window insertSubview:destinationView belowSubview:sourceView];
[UIView animateWithDuration:0.4
animations:^{
destinationView.center = CGPointMake(sourceView.center.x, sourceView.center.y);
sourceView.center = CGPointMake(sourceView.center.x, 0 - 2*destinationView.center.y);
}
completion:^(BOOL finished){
[[self destinationViewController] dismissViewControllerAnimated:NO completion:nil];
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment