UIViewAdditions 1.0.0

UIViewAdditions 1.0.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年4月

John Wong 维护。



  • 作者
  • Josh Brown

Build Status

为 UIView 提供便利方法,并巧妙地将其打包在一个分类中。

为以下属性添加了 getter 和 setter 到 UIView 中

top - 视图的顶部(frame.origin.y

bottom - 视图的底部(frame.origin.y + frame.size.height

left - 视图的左侧(frame.origin.x

right - 视图的右侧(frame.origin.x + frame.size.width

centerX - 视图的中心 x 位置(center.x

centerY - 视图的中心 y 位置(center.y

height - 视图的高度(frame.size.height

width - 视图的宽度(frame.size.width

示例

UIView *blackBox = [[UIView alloc] init];
blackBox.backgroundColor = [UIColor blackColor];
blackBox.width = 40;
blackBox.height = 40;
[self.view addSubview:blackBox];

UIView *whiteBox = [[UIView alloc] init];
whiteBox.backgroundColor = [UIColor whiteColor];
whiteBox.width = 80;
whiteBox.height = 80;
whiteBox.left = blackBox.right;
[self.view addSubview:whiteBox];

有关更多示例,请参阅 RSViewController.m

入门

在项目中使用 UIViewAdditions 非常简单;只需将 Classes 文件夹中的两个文件(UIView+RSAdditions.h/m)复制到您的项目中。然后在您的类中导入 #import "UIView+RSAdditions.h"