-
Notifications
You must be signed in to change notification settings - Fork 2
/
RAFlipReplaceSegue.m
42 lines (34 loc) · 1.09 KB
/
RAFlipReplaceSegue.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// RAFlipReplaceSegue.m
// Flickr Maps
//
// Created by Ryan Artecona on 10/12/12.
// Copyright (c) 2012 Ryan Artecona. All rights reserved.
//
// based on code from http://jrwren.wrenfam.com/blog/2012/02/01/storyboard-custom-segue-for-custom-pushviewcontroller-animation/
#import "RAFlipReplaceSegue.h"
@implementation RAFlipReplaceSegue
-(void) perform
{
UIViewController *destVC = self.destinationViewController;
UIViewController *sourceVC = self.sourceViewController;
[destVC viewWillAppear:YES];
destVC.view.frame = sourceVC.view.frame;
[UIView transitionFromView:sourceVC.view
toView:destVC.view
duration:0.7
options:self.transitionStyle
completion:^(BOOL finished)
{
[destVC viewDidAppear:YES];
UINavigationController *nav = sourceVC.navigationController;
// push the new destVC
[nav pushViewController:destVC animated:NO];
// manually pop the sourceVC
NSMutableArray *newNavVCs = [nav.viewControllers mutableCopy];
[newNavVCs removeObject:sourceVC];
nav.viewControllers = newNavVCs;
}
];
}
@end