-
Notifications
You must be signed in to change notification settings - Fork 89
/
UIView+DCAnimationKit.h
249 lines (207 loc) · 8.1 KB
/
UIView+DCAnimationKit.h
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//////////////////////////////////////////////////////////////////////////////////////
//
// UIView+AnimationKit.h
//
// Created by Dalton Cherry on 3/20/14.
//
//////////////////////////////////////////////////////////////////////////////////////
#import <UIKit/UIKit.h>
typedef void (^DCAnimationFinished)(void);
@interface UIView (DCAnimationKit)
///-------------------------------
/// @name coordinate manipulation
///-------------------------------
/**
set the x location you want the view to set
@param x is the x coordinate you want to set.
@param time is the duration of the animation.
@param finished is called when the animation finishes
*/
-(void)setX:(CGFloat)x duration:(NSTimeInterval)time finished:(DCAnimationFinished)finished;
/**
set the x location you want the view to move to.
@param x is the x coordinate you want to move to.
@param finished is called when the animation finishes
*/
-(void)setX:(CGFloat)x finished:(DCAnimationFinished)finished;
/**
move the x location (e.g. the x of the view's frame is 200 and x is 50,
then the x coordinate of the view's frame will be 250).
@param x is the offset of the x coordinate you want to move by.
@param time is the duration of the animation.
@param finished is called when the animation finishes
*/
-(void)moveX:(CGFloat)x duration:(NSTimeInterval)time finished:(DCAnimationFinished)finished;
/**
move the x location (e.g. the x of the view's frame is 200 and x is 50,
then the x coordinate of the view's frame will be 250).
@param x is the offset of the x coordinate you want to move by.
@param finished is called when the animation finishes
*/
-(void)moveX:(CGFloat)x finished:(DCAnimationFinished)finished;
/**
set the y location you want the view to set
@param y is the x coordinate you want to set.
@param time is the duration of the animation.
@param finished is called when the animation finishes
*/
-(void)setY:(CGFloat)y duration:(NSTimeInterval)time finished:(DCAnimationFinished)finished;
/**
set the y location you want the view to set
@param y is the y coordinate you want to set.
@param finished is called when the animation finishes
*/
-(void)setY:(CGFloat)y finished:(DCAnimationFinished)finished;
/**
move the y location (e.g. the y of the view's frame is 200 and y is 50,
then the y coordinate of the view's frame will be 250).
@param y is the offset of the y coordinate you want to move by.
@param time is the duration of the animation.
@param finished is called when the animation finishes
*/
-(void)moveY:(CGFloat)y duration:(NSTimeInterval)time finished:(DCAnimationFinished)finished;
/**
move the y location (e.g. the y of the view's frame is 200 and y is 50,
then the y coordinate of the view's frame will be 250).
@param y is the offset of the y coordinate you want to move by.
@param finished is called when the animation finishes
*/
-(void)moveY:(CGFloat)y finished:(DCAnimationFinished)finished;
/**
set the point you want the view to set to.
@param point is the x and y coordinate you want to set.
@param time is the duration of the animation.
@param finished is called when the animation finishes
*/
-(void)setPoint:(CGPoint)point duration:(NSTimeInterval)time finished:(DCAnimationFinished)finished;
/**
set the point you want the view to set to.
@param point is the x and y coordinate you want to set.
@param finished is called when the animation finishes
*/
-(void)setPoint:(CGPoint)point finished:(DCAnimationFinished)finished;
/**
move the x and y location (e.g. x,y is 10,20 and the point is 30,30,
then the x and y coordinates of the view's frame will be 40,50).
@param point is the offset of the x,y coordinates you want to move by.
@param time is the duration of the animation.
@param finished is called when the animation finishes
*/
-(void)movePoint:(CGPoint)point duration:(NSTimeInterval)time finished:(DCAnimationFinished)finished;
/**
move the x and y location (e.g. x,y is 10,20 and the point is 30,30,
then the x and y coordinates of the view's frame will be 40,50).
@param point is the offset of the x,y coordinates you want to move by.
@param finished is called when the animation finishes
*/
-(void)movePoint:(CGPoint)point finished:(DCAnimationFinished)finished;
/**
set the degrees of rotation on the view
@param r is the degrees you want the view to be rotated by. This would be a value between 0 and 360.
@param time is the duration of the animation.
@param finished is called when the animation finishes
*/
-(void)setRotation:(CGFloat)r duration:(NSTimeInterval)time finished:(DCAnimationFinished)finished;
/**
set the degrees of rotation on the view
@param r is the degrees you want the view to be rotated by. This would be a value between 0 and 360.
@param finished is called when the animation finishes
*/
-(void)setRotation:(CGFloat)r finished:(DCAnimationFinished)finished;
/**
move the view by a degree of rotation
@param r is the degrees you want the view to be rotated by. This would be a value between 0 and 360.
@param time is the duration of the animation.
@param finished is called when the animation finishes
*/
-(void)moveRotation:(CGFloat)r duration:(NSTimeInterval)time finished:(DCAnimationFinished)finished;
/**
move the view by a degree of rotation
@param r is the degrees you want the view to be rotated by. This would be a value between 0 and 360.
@param finished is called when the animation finishes
*/
-(void)moveRotation:(CGFloat)r finished:(DCAnimationFinished)finished;
///-------------------------------
/// @name Attention grabbers
///-------------------------------
/**
preform the bounce animation.
@param finished is called when the animation finishes
*/
-(void)bounce:(DCAnimationFinished)finished;
/**
preform the bounce animation.
@param height is how many px to bounce up by. Default is 10.
@param finished is called when the animation finishes
*/
-(void)bounce:(CGFloat)height finished:(DCAnimationFinished)finished;
/**
preform the pulse animation.
@param finished is called when the animation finishes
*/
-(void)pulse:(DCAnimationFinished)finished;
/**
preform the shake animation.
@param finished is called when the animation finishes
*/
-(void)shake:(DCAnimationFinished)finished;
/**
preform the swing animation.
@param finished is called when the animation finishes
*/
-(void)swing:(DCAnimationFinished)finished;
/**
preform the tada animation.
@param finished is called when the animation finishes
*/
-(void)tada:(DCAnimationFinished)finished;
///-------------------------------
/// @name Intros
///-------------------------------
typedef NS_ENUM(NSInteger, DCAnimationDirection) {
DCAnimationDirectionTop,
DCAnimationDirectionBottom,
DCAnimationDirectionLeft,
DCAnimationDirectionRight
};
/**
The view enters from a direction and snaps into place.
@param view is the superview you want to snap into. It will add itself as a subview of view.
@param direction is the direction to enter from.
*/
-(void)snapIntoView:(UIView*)view direction:(DCAnimationDirection)direction;
/**
The view enters from a direction and bounce into place.
@param view is the superview you want to bounce into. It will add itself as a subview of view.
@param direction is the direction to enter from.
*/
-(void)bounceIntoView:(UIView*)view direction:(DCAnimationDirection)direction;
/**
The view expands into it's frame place.
@param view is the superview you want to expand into. It will add itself as a subview of view.
@param finished is called when the animation finishes
*/
-(void)expandIntoView:(UIView*)view finished:(DCAnimationFinished)finished;
///-------------------------------
/// @name Outros
///-------------------------------
/**
The view compress into it's frame place.
@param finished is called when the animation finishes
*/
-(void)compressIntoView:(DCAnimationFinished)finished;
/**
The view hinges and falls off screen.
@param finished is called when the animation finishes
*/
-(void)hinge:(DCAnimationFinished)finished;
/**
The view will drop based on gravity.
@param finished is called when the animation finishes
*/
-(void)drop:(DCAnimationFinished)finished;
/**
Remove the current animator animations applied.
*/
-(void)removeCurrentAnimations;
@end