-
Notifications
You must be signed in to change notification settings - Fork 0
/
XYZSwitchToLyricsSegue.m
39 lines (30 loc) · 1.16 KB
/
XYZSwitchToLyricsSegue.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
//
// XYZSwitchToLyricsSegue.m
// KnowLyrics
//
// Created by David Tien on 12/6/13.
// Copyright (c) 2013 David Tien. All rights reserved.
//
#import "XYZSwitchToLyricsSegue.h"
@implementation XYZSwitchToLyricsSegue
- (void)perform {
UIViewController* source = (UIViewController *)self.sourceViewController;
UIViewController* destination = (UIViewController *)self.destinationViewController;
CGRect sourceFrame = source.view.frame;
sourceFrame.origin.x = -sourceFrame.size.width;
CGRect destFrame = destination.view.frame;
destFrame.origin.x = destination.view.frame.size.width;
destination.view.frame = destFrame;
destFrame.origin.x = 0;
[source.view.superview addSubview:destination.view];
[UIView animateWithDuration:1.0
animations:^{
source.view.frame = sourceFrame;
destination.view.frame = destFrame;
}
completion:^(BOOL finished) {
UIWindow *window = source.view.window;
[window setRootViewController:destination];
}];
}
@end