iOS - UIView 类目关于 frame 的封装
2017-06-14 17:56
211 查看
以下是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;
}
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;
}
相关文章推荐
- iOS 基础-----关于UIView 的 frame 与 bounds
- iOS 基础-----关于UIView 的 frame 与 bounds
- iOS 基础-----关于UIView 的 frame 与 bounds
- iOS 基础-----关于UIView 的 frame 与 bounds
- ios-坐标系统(详解UIView的frame、bounds跟center属性[图])
- IOS UIView之frame和bounds属性区别
- IOS——关于UIView的autoresizingMask属性的研究
- iOS开发笔记--关于设置UIView的背景为图片的方法以及问题
- ios-坐标系统(详解UIView的frame、bounds跟center属性[图])
- IOS 关于如何修改facebook内部封装好的控件属性(如何修改封装好的控件)
- iOS----关于UIView的autoresizingMask属性的研究
- iOS开发UI篇—核心动画(UIView封装动画)
- ios-坐标系统(详解UIView的frame、bounds跟center属性[图])
- 关于iOS的UIView的一点笔记
- ios 关于 initWithFrame 方法
- iOS开发UI篇—核心动画(UIView封装动画)(转摘)
- iOS动画:UIView动画和CALayer动画(CABasicAnimation、CAKeyframeAnimation的使用)
- ios-坐标系统(详解UIView的frame、bounds跟center属性[图])
- IOS开发:关于设置UIView的背景为图片的方法以及问题
- iOS 关于UIView的userInteractionEnabled属性(多层视图到点击事件)