本篇文章主要给大家详细分析了ios开发中scrollView上使用masonry的详细知识内容,需要的朋友参考下吧。
使用scrollView的一个子视图对contentSize进行调整
_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
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上
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进行重新约束
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(childV.mas_bottom);
}];
以上就是本次给大家整理的全部内容,如果还有任何不明白的地方可以在下方的留言区讨论,感谢你对编程学习网的支持。
织梦狗教程
本文标题为:详解ios中scrollView上使用masonry
基础教程推荐
猜你喜欢
- IOS 播放系统提示音使用总结(AudioToolbox) 2023-03-01
- Flutter绘图组件之CustomPaint使用详解 2023-05-12
- Android多返回栈技术 2023-04-15
- iOS开发教程之XLForm的基本使用方法 2023-05-01
- Android中的webview监听每次URL变化实例 2023-01-23
- android studio按钮监听的5种方法实例详解 2023-01-12
- Android开发使用RecyclerView添加点击事件实例详解 2023-06-15
- IOS应用内跳转系统设置相关界面的方法 2022-11-20
- Flutter手势密码的实现示例(附demo) 2023-04-11
- 解决Android Studio突然不显示logcat日志的问题 2023-02-04
