how to set scrollview content size with auto layout?

后端 未结 1 1803
隐瞒了意图╮
隐瞒了意图╮ 2020-12-20 08:41

I have one screen where I have added 1 scroll view on self view. Tab bar and navigation bar both are there and for iPhone 4 view height is 455.I have added more content on s

相关标签:
1条回答
  • 2020-12-20 09:19

    Here is how to set up the size of the contentView in Auto Layout:

    1. Add a view to your scrollView. This should be the only top level view on your scrollView and it will serve as your contentView.
    2. Constrain the left, top, right, and bottom edges of this contentView to the left, top, right, and bottom of the scrollView with offsets of 0.
    3. To size the contentView, add width and height constraints to the contentView. If you want it to scroll, the width and height must be larger than the width and height of the scrollView itself. If you only want to scroll vertically, set the width of the contentView to be equal to the width of the scrollView.
    0 讨论(0)
提交回复
热议问题