Skip to content

Instantly share code, notes, and snippets.

@AndrejJurkin
Created October 4, 2017 12:29
Show Gist options
  • Save AndrejJurkin/f0c97ee848a0e2ee7b4920884e698c1f to your computer and use it in GitHub Desktop.
Save AndrejJurkin/f0c97ee848a0e2ee7b4920884e698c1f to your computer and use it in GitHub Desktop.
ScrollView with auto-layout
- Add a Scroll View as a Sub View of the Main View
- Select the Scroll View and uncheck "Constrain to margins" and pin top, left, right, bottom, constraints
- Add a UIView as a subview of the Scroll View. Name this view "Content View"
- Select the Content View and pin top, left, right, and bottom constraints. Then add a center horizontally constraint.
- Next from the Content View to the Main View add equal width and equal height constraints.
- Add whatever elements you need inside the Content View. Pin top, left, right, and height constraints to the elements that were just added.
- On the bottom most item inside the Content View pin a bottom constraint. Select this constraint and change to "Greater Than or Equal". Change the constant to 20.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment