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 底部设置约束就可以。
参考地址

你可能感兴趣的:(UIScrollView 使用 Auto Layout 创建,contentSize 自适应)