-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIView+WUHExpand.m
More file actions
110 lines (85 loc) · 1.87 KB
/
Copy pathUIView+WUHExpand.m
File metadata and controls
110 lines (85 loc) · 1.87 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
#import "UIView+WUHExpand.h"
@implementation UIView(Frame)
-(CGFloat)x
{
return self.frame.origin.x;
}
-(void)setX:(CGFloat)x
{
self.frame = CGRectMake(x, self.frame.origin.y, self.bounds.size.width, self.bounds.size.height);
}
-(CGFloat)y
{
return self.frame.origin.y;
}
-(void)setY:(CGFloat)y
{
self.frame = CGRectMake(self.frame.origin.x, y, self.bounds.size.width, self.bounds.size.height);
}
-(CGPoint)origin
{
return self.frame.origin;
}
-(void)setOrigin:(CGPoint)point
{
self.frame = CGRectMake(point.x, point.y, self.width, self.height);
}
-(CGFloat)width
{
return self.bounds.size.width;
}
-(void)setWidth:(CGFloat)width
{
self.frame = CGRectMake(self.x, self.y, width, self.height);
}
-(CGFloat)height
{
return self.bounds.size.height;
}
-(void)setHeight:(CGFloat)height
{
self.frame = CGRectMake(self.x, self.y, self.width, height);
}
-(CGSize)size
{
return self.bounds.size;
}
-(void)setSize:(CGSize)size
{
self.frame = CGRectMake(self.x, self.y, size.width, size.height);
}
-(CGRect)frameInWindow
{
return [self.superview convertRect:self.frame toView:self.window];
}
@end
@implementation UIView(layer)
-(void)setCornerRadius:(CGFloat)cornerRadius
{
self.layer.cornerRadius = cornerRadius;
}
-(void)setBorderColor:(UIColor *)borderColor
{
self.layer.borderColor = borderColor.CGColor;
}
-(void)setBorderWidth:(CGFloat)borderWidth
{
self.layer.borderWidth = borderWidth;
}
@end
@implementation UIView(subView)
-(void)RemoveAllSubViews
{
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
}
-(UIView *)GetSubViewByTag:(NSInteger)tag
{
__block UIView * subView;
[self.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([[obj valueForKey:@"tag"] integerValue] == tag) {
subView = obj;
}
}];
return subView;
}
@end