使用scrollView的一个子视图对contentSize进行调整
?
|
1
2
3
4
5
|
_scroll_Bg = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 100, SCREEN_W, 200)];
_scroll_Bg.pagingEnabled = YES;
_scroll_Bg.delegate = self;
_scroll_Bg.backgroundColor = [UIColor redColor];
[self.view addSubview:_scroll_Bg];
|
1,现在scrollView添加一个主要子视图,大小贴合scrollView
?
|
1
2
3
4
5
6
7
|
UIView *bgView = [[UIView alloc] init];
bgView.backgroundColor = [UIColor blueColor];
[_scroll_Bg addSubview:bgView];
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.bottom.and.right.equalTo(_scroll_Bg).with.insets(UIEdgeInsetsZero);
make.width.equalTo(_scroll_Bg);
}];
|
2,此后所有子视图都需添加在此bgView上
?
|
1
2
3
4
5
6
7
8
|
UIView *childV = [[UIView alloc] init];
childV.backgroundColor = [UIColor cyanColor];
[bgView addSubview:childV];
[childV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(0);
make.top.mas_equalTo(250);
make.height.mas_equalTo(1000);
}];
|
3,以最后所加子视图为准,再对bgView进行重新约束
?
|
1
2
3
|
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(childV.mas_bottom);
}];
|
以上就是本次给大家整理的全部内容,如果还有任何不明白的地方可以在下方的留言区讨论,感谢你对快网idc的支持。
相关文章
猜你喜欢
- 64M VPS建站:能否支持高流量网站运行? 2025-06-10
- 64M VPS建站:怎样选择合适的域名和SSL证书? 2025-06-10
- 64M VPS建站:怎样优化以提高网站加载速度? 2025-06-10
- 64M VPS建站:是否适合初学者操作和管理? 2025-06-10
- ASP.NET自助建站系统中的用户注册和登录功能定制方法 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-05-29 86
-
2025-05-27 59
-
2025-06-04 106
-
2025-05-24 107
-
2025-05-29 19
热门评论

