UIScrollView 使用 Auto Layout 创建,contentSize 自适应

UI 布局在小屏幕手机上显示不完全的时候。

SOLUTION
The problem is that you need a bottom/footer view for AutoLayout to know the contentSize of the entire content.
If you add this code to the code I posted here in my first question you will have a nice scrolling ScrollView 👍

    // NECESSARY TO SCROLL!
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectZero];
    bottomView.backgroundColor = [UIColor redColor];
    [_scrollView addSubview:bottomView];
    // last one, pin to bottom and right, this dictates content size height
    [bottomView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(view3.bottom).offset(10);
        make.left.equalTo(_scrollView.left).offset(10);
        make.width.equalTo(_scrollView.width).offset(-20);
        make.height.equalTo(@50);
        make.bottom.equalTo(_scrollView.bottom).offset(-10);
    }];

需要设置 footView 的 bottom 底部设置约束就可以。
参考地址

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容