-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEverestAnimations.m
189 lines (188 loc) · 7.58 KB
/
EverestAnimations.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
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
#include "EverestAnimations.h"
@implementation EverestAnimations
+ (void)shrinkAnimationForIconView:(UIView *)iconView
withDuration:(float)duration {
[UIView animateWithDuration:duration * 0.3f
delay:0.0f
options:UIViewAnimationOptionCurveLinear
animations:^{
CGFloat minimumSize = 0.00001f;
iconView.transform =
CGAffineTransformMakeScale(minimumSize, minimumSize);
}
completion:^(BOOL finished) {
if (finished) {
// Enlarge transform to oversize
[UIView animateWithDuration:duration * 0.25f
delay:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^{
CGFloat oversize = 1.3f;
iconView.transform = CGAffineTransformScale(
CGAffineTransformIdentity, oversize, oversize);
}
completion:^(BOOL finished) {
// Bouncing back
if (finished) {
[UIView animateWithDuration:duration * 0.25f
delay:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^{
iconView.transform =
CGAffineTransformIdentity;
}
completion:nil];
}
}];
}
}];
}
+ (void)fadeOutAnimationForIconView:(UIView *)iconView
withDuration:(float)duration {
[UIView animateWithDuration:duration
delay:0.0f
options:UIViewAnimationOptionCurveLinear
animations:^{
// float degrees = 3 * 360;
// iconView.transform =
// CGAffineTransformMakeRotation(degrees * M_PI/180);
iconView.transform =
CGAffineTransformMakeScale(0.00001f, 0.00001f);
}
completion:nil];
}
+ (void)spinAnimationForIconView:(UIView *)iconView
withDuration:(float)duration {
}
+ (void)flipVerticalOnceAnimationForIconView:(UIView *)iconView
withDuration:(float)duration {
[UIView animateWithDuration:duration
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
iconView.transform = CGAffineTransformMakeScale(1, -1);
}
completion:nil];
}
+ (void)flipVerticalAnimationForIconView:(UIView *)iconView
withDuration:(float)duration {
[UIView animateWithDuration:duration * 0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
iconView.transform = CGAffineTransformMakeScale(1, -1);
}
completion:^(BOOL finished) {
[UIView animateWithDuration:duration * 0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
iconView.transform =
CGAffineTransformMakeScale(1, 1);
}
completion:nil];
}];
}
+ (void)flipHorizontalOnceAnimationForIconView:(UIView *)iconView
withDuration:(float)duration {
[UIView animateWithDuration:duration
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
iconView.transform = CGAffineTransformMakeScale(-1, 1);
}
completion:nil];
}
+ (void)flipHorizontalAnimationForIconView:(UIView *)iconView
withDuration:(float)duration {
[UIView animateWithDuration:duration * 0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
iconView.transform = CGAffineTransformMakeScale(-1, 1);
}
completion:^(BOOL finished) {
[UIView animateWithDuration:duration * 0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
iconView.transform =
CGAffineTransformMakeScale(1, 1);
}
completion:nil];
}];
}
+ (void)rotateClockwiseAnimationForIconView:(UIView *)iconView
withDuration:(float)duration {
[UIView animateWithDuration:duration * 0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseIn
animations:^(void) {
float degrees = 180; // the value in degrees
iconView.transform = CGAffineTransformMakeRotation(degrees * PI / 180);
}
completion:^(BOOL finished) {
[UIView animateWithDuration:duration * 0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^() {
float degrees = 0; // the value in degrees
iconView.transform = CGAffineTransformMakeRotation(
degrees * PI / 180);
}
completion:nil];
}];
}
+ (void)rotateCounterClockwiseAnimationForIconView:(UIView *)iconView
withDuration:(float)duration {
[UIView animateWithDuration:duration * 0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseIn
animations:^(void) {
float degrees = 181; // the value in degrees (if anyone knows how to
// rotate backwards in CoreAnimation lemme know)
iconView.transform = CGAffineTransformMakeRotation(degrees * PI / 180);
}
completion:^(BOOL finished) {
[UIView animateWithDuration:duration * 0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^() {
float degrees = 1; // the value in degrees (doesn't
// even make a full rotation lol)
iconView.transform = CGAffineTransformMakeRotation(
degrees * PI / 180);
}
completion:nil];
}];
}
+(void)tadaAnimationForIconView:(UIView *)iconView withDuration:(float)duration {
[iconView tada:NULL];
}
+(void)bounceAnimationForIconView:(UIView *)iconView withDuration:(float)duration {
[iconView bounce:NULL];
}
+(void)pulseAnimationForIconView:(UIView *)iconView withDuration:(float)duration {
[iconView pulse:NULL];
}
+(void)swingAnimationForIconView:(UIView *)iconView withDuration:(float)duration {
[iconView swing:NULL];
}
+(void)hingeAnimationForIconView:(UIView *)iconView withDuration:(float)duration {
[iconView hinge:NULL];
}
+(void)dropAnimationForIconView:(UIView *)iconView withDuration:(float)duration {
[iconView drop:NULL];
}
+(void)squeezeAnimationForIconView:(UIView *)iconView withDuration:(float)duration {
[UIView animateWithDuration:duration // * 0.3f
delay:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^{
CGFloat minimumSize = 0.001f;
iconView.transform =
CGAffineTransformMakeScale(minimumSize, 1);
}
completion:nil];
}
@end