-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComposeViewController.m
More file actions
196 lines (156 loc) · 5.85 KB
/
Copy pathComposeViewController.m
File metadata and controls
196 lines (156 loc) · 5.85 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//
// ComposeViewController.m
// HomeWork3
//
// Created by Kelly Xu on 3/20/14.
// Copyright (c) 2014 iosbootcamp. All rights reserved.
//
#import "ComposeViewController.h"
@interface ComposeViewController ()
@property (strong, nonatomic) IBOutlet UIView *textView;
@property (strong, nonatomic) IBOutlet UIView *photoView;
@property (strong, nonatomic) IBOutlet UIView *quoteView;
@property (strong, nonatomic) IBOutlet UIView *linkView;
@property (strong, nonatomic) IBOutlet UIView *chatView;
@property (strong, nonatomic) IBOutlet UIView *videoView;
@property (nonatomic,assign) BOOL animating;
- (IBAction)onNeverMindButton:(id)sender;
@end
@implementation ComposeViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.textView.alpha = 0;
self.photoView.alpha = 0;
self.quoteView.alpha = 0;
self.linkView.alpha = 0;
self.chatView.alpha = 0;
self.videoView.alpha = 0;
self.animating = YES;
[self setZeroPosition];
[self startAnimation];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)onNeverMindButton:(id)sender {
[self endAnimation];
[self performSelector:@selector(dismissSubView) withObject:nil afterDelay:0.7];
}
-(void)setZeroPosition{
CGRect frame1 = self.textView.frame;
CGRect frame2 = self.photoView.frame;
CGRect frame3 = self.quoteView.frame;
CGRect frame4 = self.linkView.frame;
CGRect frame5 = self.chatView.frame;
CGRect frame6 = self.videoView.frame;
frame1.origin.y = 500;
frame2.origin.y = 500;
frame3.origin.y = 500;
frame4.origin.y = 580;
frame5.origin.y = 580;
frame6.origin.y = 580;
self.textView.frame = frame1;
self.photoView.frame = frame2;
self.quoteView.frame = frame3;
self.linkView.frame = frame4;
self.chatView.frame = frame5;
self.videoView.frame = frame6;
}
-(void)startAnimation{
CGRect frame1 = self.textView.frame;
CGRect frame2 = self.photoView.frame;
CGRect frame3 = self.quoteView.frame;
CGRect frame4 = self.linkView.frame;
CGRect frame5 = self.chatView.frame;
CGRect frame6 = self.videoView.frame;
frame1.origin.y -= 350;
frame2.origin.y -= 350;
frame3.origin.y -= 350;
frame4.origin.y -= 310;
frame5.origin.y -= 310;
frame6.origin.y -= 310;
[UIView animateWithDuration:0.3 delay:0.1 usingSpringWithDamping:0.6
initialSpringVelocity:0.7 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.textView.alpha = 1;
self.textView.frame = frame1;
} completion:nil];
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.6
initialSpringVelocity:0.7 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.photoView.alpha = 1;
self.photoView.frame = frame2;
} completion:nil];
[UIView animateWithDuration:0.3 delay:0.1 usingSpringWithDamping:0.6
initialSpringVelocity:0.7 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.quoteView.alpha = 1;
self.quoteView.frame = frame3;
} completion:nil];
[UIView animateWithDuration:0.4 delay:0.3 usingSpringWithDamping:0.6
initialSpringVelocity:0.7 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.linkView.alpha = 1;
self.linkView.frame = frame4;
} completion:nil];
[UIView animateWithDuration:0.3 delay:0.2 usingSpringWithDamping:0.6
initialSpringVelocity:0.7 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.chatView.alpha = 1;
self.chatView.frame = frame5;
} completion:nil];
[UIView animateWithDuration:0.4 delay:0.3 usingSpringWithDamping:0.6
initialSpringVelocity:0.7 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.videoView.alpha = 1;
self.videoView.frame = frame6;
} completion:nil];
}
-(void)endAnimation{
CGRect frame1 = self.textView.frame;
CGRect frame2 = self.photoView.frame;
CGRect frame3 = self.quoteView.frame;
CGRect frame4 = self.linkView.frame;
CGRect frame5 = self.chatView.frame;
CGRect frame6 = self.videoView.frame;
frame1.origin.y -= 550;
frame2.origin.y -= 550;
frame3.origin.y -= 550;
frame4.origin.y -= 510;
frame5.origin.y -= 510;
frame6.origin.y -= 510;
[UIView animateWithDuration:0.2 delay:0.1 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.textView.alpha = 0;
self.textView.frame = frame1;
} completion:nil];
[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.photoView.alpha = 0;
self.photoView.frame = frame2;
} completion:nil];
[UIView animateWithDuration:0.2 delay:0.1 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.quoteView.alpha = 0;
self.quoteView.frame = frame3;
} completion:nil];
[UIView animateWithDuration:0.3 delay:0.3 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.linkView.alpha = 0;
self.linkView.frame = frame4;
} completion:nil];
[UIView animateWithDuration:0.2 delay:0.2 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.chatView.alpha = 0;
self.chatView.frame = frame5;
} completion:nil];
[UIView animateWithDuration:0.3 delay:0.3 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.videoView.alpha = 0;
self.videoView.frame = frame6;
} completion:nil];
}
-(void)dismissSubView{
[self setZeroPosition];
[self.view removeFromSuperview];
}
@end