UIScrollView + Masonry 布局
2020-06-21 本文已影响0人
我叫山鸡_
UIScrollView + Masonry 的布局方式有很多种,我这里采用的是在UIScrollView 上添加contentView,将视图添加在contentView 上,使最后一个视图与contentView的边距保持一致,这样就能使contentView 撑大,UIScrollView 也能随之变大.
[self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
[self.mainView addSubview:self.contentView];
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.bottom.equalTo(self.mainView);
// 1. 设置内容视图的高
make.height.equalTo(self.mainView.mas_height);
}];
// 2.中间添加所需要的视图
// 3. 内容视图的右边距等于最后视图的右边距 可以让内容视图的宽撑开
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(view5.mas_right);
}];