-
Notifications
You must be signed in to change notification settings - Fork 11
/
UIViewUtilities.mm
63 lines (57 loc) · 1.95 KB
/
UIViewUtilities.mm
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
#import "UIViewUtilities.h"
@implementation UIView (Utilities)
- (void)transitionInBottom {
float slideDist = self.superview.bounds.size.height -
(self.center.y - self.bounds.size.height * 0.5);
// move it down then animate it back up
self.center = CGPointMake(self.center.x, self.center.y + slideDist);
[UIView animateWithDuration:0.25
delay:0
options:nil
animations:^{
self.center =
CGPointMake(self.center.x, self.center.y - slideDist);
}
completion:^(BOOL completed){
}];
}
- (void)transitionOutBottom {
float slideDist = self.superview.bounds.size.height -
(self.center.y - self.bounds.size.height * 0.5);
[UIView animateWithDuration:0.25
delay:0
options:nil
animations:^{
self.center = CGPointMake(self.center.x, self.center.y + slideDist);
}
completion:^(BOOL completed) {
[self removeFromSuperview];
}];
}
- (void)transitionInTop {
float slideDist = self.center.y + self.bounds.size.height * 0.5;
// move it up then animate it back down
self.center = CGPointMake(self.center.x, self.center.y - slideDist);
[UIView animateWithDuration:0.25
delay:0
options:nil
animations:^{
self.center =
CGPointMake(self.center.x, self.center.y + slideDist);
}
completion:^(BOOL completed){
}];
}
- (void)transitionOutTop {
float slideDist = self.center.y + self.bounds.size.height * 0.5;
[UIView animateWithDuration:0.25
delay:0
options:nil
animations:^{
self.center = CGPointMake(self.center.x, self.center.y - slideDist);
}
completion:^(BOOL completed) {
[self removeFromSuperview];
}];
}
@end