Masonry的使用3
2016-01-29 22:17
183 查看
1.
#import "ViewController.h" //只要添加了这个宏,就不用带 mas_前缀 #define MAS_SHORTHAND //只要添加了这个宏,equalTo就等价于mas_equalTo #define MAS_SHORTHAND_GLOBALS //这个头文件一定要放在前面2个宏的后面 #import "Masonry.h"2.
- (void)viewDidLoad { [super viewDidLoad]; // 1.创建控件 UIView *blueView = [[UIView alloc] init]; blueView.backgroundColor = [UIColor blueColor]; [self.view addSubview:blueView]; UIView *redView = [[UIView alloc] init]; redView.backgroundColor = [UIColor redColor]; [self.view addSubview:redView]; // 2.添加约束 CGFloat margin = 20; CGFloat height = 50; [blueView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.left).offset(margin); make.right.equalTo(redView.left).offset(-margin); make.bottom.equalTo(self.view.bottom).offset(-margin); make.height.equalTo(height); make.top.equalTo(redView.top); make.bottom.equalTo(redView.bottom); make.width.equalTo(redView.width); }]; [redView makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.view.right).offset(-margin); }]; }
相关文章推荐
- oracle system change number(SCN)
- boa服务器CGI相关的一些错误解决方法
- GIS大讨论(十一):当前地理信息产业发展动向与趋势
- 动态规划-搬寝室
- Http与Servlet工具类
- DMG 机床集团
- 数据隐藏技术
- 观察者模式
- BZOJ_P3997 [TJOI2015]组合数学(动态规划)
- 浮点数
- Android--viewpager学习
- iOS UIButton倒计时闪烁问题
- 安卓基础----短信监听
- android 导入数据库
- nyoj-115城市平乱-各种解法
- [UIWindow endDisablingInterfaceAutorotationAnimated:] called on UITextEffectsWindow: ...without matc
- UVA 1493 Draw a Mess 并查集
- 编写类String 的构造函数、析构函数和赋值函数
- NPOI基础入门(旧版本)
- NPOI基础入门(旧版本)