forked from andrewwiik/Intelix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ITXAnimatedSeperatedCornersView.m
75 lines (59 loc) · 2.16 KB
/
ITXAnimatedSeperatedCornersView.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
#import <Intelix/ITXAnimatedSeperatedCornersView.h>
@implementation ITXAnimatedSeperatedCornersView
- (id)init {
self = [super init];
if (self) {
_topView = [UIView new];
_topView.backgroundColor = [UIColor blackColor];
_topView.clipsToBounds = YES;
_bottomView = [UIView new];
_bottomView.backgroundColor = [UIColor blackColor];
_bottomView.clipsToBounds = YES;
_topMaskView = [[ITXAnimatedCornersView alloc] init];
_topMaskView.backgroundColor = [UIColor blackColor];
_topView.maskView = _topMaskView;
_bottomMaskView = [[ITXAnimatedCornersView alloc] init];
_bottomMaskView.backgroundColor = [UIColor blackColor];
_bottomView.maskView = _bottomMaskView;
_containerView = [[UIView alloc] init];
//_containerView.backgroundColor = [UIColor blackColor];
_topCornerRadius = 0;
_bottomCornerRadius = 0;
_topInset = 0;
_bottomInset = 0;
[_containerView addSubview:_topView];
[_containerView addSubview:_bottomView];
self.maskView = _containerView;
self.backgroundColor = [UIColor redColor];
}
return self;
}
- (void)setTopCornerRadius:(CGFloat)cornerRadius {
//_topMaskView.layer.cornerRadius = cornerRadius;
_topCornerRadius = cornerRadius;
}
- (void)setBottomCornerRadius:(CGFloat)cornerRadius {
//_bottomMaskView.layer.cornerRadius = cornerRadius;
_bottomCornerRadius = cornerRadius;
}
- (void)setTopInset:(CGFloat)inset {
_topInset = inset;
}
- (void)setBottomInset:(CGFloat)inset {
_bottomInset = inset;
}
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat halfHeight = self.bounds.size.height/2;
CGFloat width = self.bounds.size.width;
CGFloat topRadius = _topCornerRadius;
CGFloat bottomRadius = _bottomCornerRadius;
_topView.layer.cornerRadius = _topCornerRadius;
_bottomView.layer.cornerRadius = _bottomCornerRadius;
_containerView.frame = self.bounds;
_topView.frame = CGRectMake(0,0 + _topInset,width,halfHeight + topRadius);
_bottomView.frame = CGRectMake(0,halfHeight - bottomRadius - _bottomInset,width,halfHeight + bottomRadius);
_topMaskView.frame = CGRectMake(0,0,width, halfHeight - _topInset);
_bottomMaskView.frame = CGRectMake(0,0 + bottomRadius + _bottomInset,width, halfHeight - _bottomInset);
}
@end