iOS - UIView 类目关于 frame 的封装
以下是demo截图:
UIView+ZJJFrameView.m 方法:
#pragma mark - 视图底部
- (void)setBottom:(float)bottom {
CGRect rect = self.frame;
rect.origin.y = bottom - rect.size.height;
self.frame = rect;
}
- (float)bottom {
return self.frame.origin.y+self.frame.size.height;
}
#pragma mark - 视图上部
- (void)setTop:(float)top {
CGRect rect = self.frame;
rect.origin.y = top;
self.frame = rect;
}
- (float)top {
return self.frame.origin.y;
}
#pragma mark - 视图左面
- (void)setLeft:(float)left {
CGRect rect = self.frame;
rect.origin.x = left;
self.frame = rect;
}
- (float)left {
return self.frame.origin.x;
}
#pragma mark - 视图右面
- (void)setRight:(float)right {
CGRect rect = self.frame;
rect.origin.x = right - rect.size.width;
self.frame = rect;
}
- (float)right {
return self.frame.origin.x + self.frame.size.width;
}