-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIView+Extensions.m
129 lines (105 loc) · 2.83 KB
/
UIView+Extensions.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
//
// UIView+Extensions.m
//
#import "UIView+Extensions.h"
@implementation UIView (Extensions)
- (void)setBoundsX:(CGFloat)x
{
self.bounds = CGRectMake(x, self.bounds.origin.y, self.bounds.size.width, self.bounds.size.height);
}
- (CGFloat)boundsX
{
return self.bounds.origin.x;
}
- (void)setBoundsY:(CGFloat)y
{
self.bounds = CGRectMake(self.bounds.origin.x, y, self.bounds.size.width, self.bounds.size.height);
}
- (CGFloat)boundsY
{
return self.bounds.origin.y;
}
- (void)setBoundsWidth:(CGFloat)width
{
self.bounds = CGRectMake(self.bounds.origin.x, self.bounds.origin.y, width, self.bounds.size.height);
}
- (CGFloat)boundsWidth
{
return self.bounds.size.width;
}
- (void)setBoundsHeight:(CGFloat)height
{
self.bounds = CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, height);
}
- (CGFloat)boundsHeight
{
return self.bounds.size.height;
}
- (void)setFrameCenterX:(CGFloat)centerX
{
self.frame = CGRectMake((centerX - (self.frame.size.width / 2)),
self.frame.origin.y,
self.frame.size.width,
self.frame.size.height);
}
- (CGFloat)frameCenterX
{
return self.center.x;
}
- (void)setFrameCenterY:(CGFloat)centerY
{
self.frame = CGRectMake(self.frame.origin.x,
(centerY - (self.frame.size.height / 2)),
self.frame.size.width,
self.frame.size.height);
}
- (CGFloat)frameCenterY
{
return self.center.y;
}
- (void)setFrameHeight:(CGFloat)height
{
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, height);
}
- (CGFloat)frameHeight
{
return self.frame.size.height;
}
- (void)setFrameWidth:(CGFloat)width
{
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, width, self.frame.size.height);
}
- (CGFloat)frameWidth
{
return self.frame.size.width;
}
- (void)setFrameX:(CGFloat)x
{
self.frame = CGRectMake(x, self.frame.origin.y, self.frame.size.width, self.frame.size.height);
}
- (CGFloat)frameX
{
return self.frame.origin.x;
}
- (void)setFrameY:(CGFloat)y
{
self.frame = CGRectMake(self.frame.origin.x, y, self.frame.size.width, self.frame.size.height);
}
- (CGFloat)frameY
{
return self.frame.origin.y;
}
- (void)logGeometry
{
NSLog(@"\n\n");
NSLog(@"frame.origin.x: %f", self.frame.origin.x);
NSLog(@"frame.origin.y: %f", self.frame.origin.y);
NSLog(@"frame.size.width: %f", self.frame.size.width);
NSLog(@"frame.size.height: %f", self.frame.size.height);
NSLog(@"bounds.origin.x: %f", self.bounds.origin.x);
NSLog(@"bounds.origin.y: %f", self.bounds.origin.y);
NSLog(@"bounds.size.width: %f", self.bounds.size.width);
NSLog(@"bounds.size.height: %f", self.bounds.size.height);
NSLog(@"\n\n");
}
@end