Skip to content

GKMIT/scroll-view-autoLayout

Repository files navigation

scroll-view-autoLayout

How to configure a UIScrollView with Auto Layout in Interface Builder.
We saw many ios beginner developers are stuck on scrollView with dynamic width and height. We will show you a good way of handling this things. In this approach we are doing this with storyboard only. As per your requirement create your design(Any height) it will automatically take care all things.
Follow this steps:

  1. Create new project( eg. scrollViewAutoLayout).
    image 1
  2. After creating project go to Main.storyboard file.
    image 2
  3. Now you can see empty view controller on storyboard.
    image 3
  4. Drag scrollView from object library to view controller.
    image 4
  5. now it’s time to set constraint for scroll view.
  6. Set scroll view constraint (top, bottom, leading and trailing) as (0,0,0,0).
    image 5
  7. Now update the frame.
  8. Now we require contentView for scroll view.
  9. Drag view from object library to scroll View.
    image 6
  10. now it’s time to set constraint for view(inside scroll view).
    image 7
  11. Set view constraint (top, bottom, leading and trailing) as (0,0,0,0).
  12. Now you can see hierarchy like this view -> scroll view -> view(content view).
    image 8
  13. Now we need add more constraint for content view.
  • Most important step *
  1. Our content view must have equal width and equal height with parent view.
    image 9
  2. Now select height constraint of content view and set priority with low(250).
    image 10
  3. We are done with our setup.
  4. Now you can design your view with any height.
  5. Congrats you are done with scroll view with autolayout.

Found a bug?

Let us know! Send a pull request or a patch. Questions? Ask! We're here to help. We will respond to all filed issues.

Contributors

Click here to see a list of the contributors to this library.

Releases

No releases published

Packages

No packages published

Languages