-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomSegue.m
62 lines (52 loc) · 2.52 KB
/
CustomSegue.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// CustomSegue.m
// MembershipCard
//
// Created by mstr on 5/27/14.
// Copyright (c) 2014 com.hbu.com. All rights reserved.
//
#import "CustomSegue.h"
@implementation CustomSegue
- (void)perform
{
if([self.direction isEqualToString:@"RIGHTTOLEFT"])
{
UIView *sv = ((UIViewController *)self.sourceViewController).view;
UIView *dv = ((UIViewController *)self.destinationViewController).view;
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
dv.center = CGPointMake(sv.center.x + sv.frame.size.width,
dv.center.y);
[window insertSubview:dv aboveSubview:sv];
[UIView animateWithDuration:0.4
animations:^{
dv.center = CGPointMake(sv.center.x,
dv.center.y);
sv.center = CGPointMake(0 - sv.center.x,
dv.center.y);
}
completion:^(BOOL finished){
[[self sourceViewController] presentViewController:
[self destinationViewController] animated:NO completion:nil];
}];
}
else if ([self.direction isEqualToString:@"LEFTTORIGHT"]){
UIView *sv = ((UIViewController *)self.sourceViewController).view;
UIView *dv = ((UIViewController *)self.destinationViewController).view;
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
dv.center = CGPointMake(sv.center.x - sv.frame.size.width,
dv.center.y);
[window insertSubview:dv aboveSubview:sv];
[UIView animateWithDuration:0.4
animations:^{
dv.center = CGPointMake(sv.center.x,
dv.center.y);
sv.center = CGPointMake( sv.center.x+sv.frame.size.width,
dv.center.y);
}
completion:^(BOOL finished){
[[self sourceViewController] presentViewController:
[self destinationViewController] animated:NO completion:nil];
}];
}
}
@end