这个框架方便简单
框架连接:https://github.com/SnapKit/Masonry
参考于:http://www.th7.cn/Program/IOS/201502/390670.shtml
使用时直接导入头文件即可Masonry.h
- (void)viewDidLoad {
[super viewDidLoad];
[self addMasory];
}
-(void)addMasory
{
UIView *view1=[UIView new];
[view1 setBackgroundColor:[UIColor redColor]];
[self.view addSubview:view1];
UIView *view2=[UIView new];
[view2 setBackgroundColor:[UIColor blackColor]];
[self.view addSubview:view2];
[view1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view.mas_left).offset(30);
make.bottom.equalTo(self.view.mas_bottom).offset(-30);
make.right.equalTo(view2.mas_left).offset(-30);
make.height.mas_equalTo(50);
}];
[view2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view.mas_right).offset(-30);
make.bottom.equalTo(view1.mas_bottom);
make.height.equalTo(view1.mas_height);
make.width.equalTo(view1.mas_width);
}];
}
实现的效果如图:
2AC10412-3198-44E4-BA4B-D22FF86E79D2.png
网友评论