I ALWAYS forget these steps. So I am finally going to blog them so I remember.
(Xcode 8)
1. Setup UIScrollView and Your Content UIView
- Add UIScrollView to Storyboard. Size to your liking.
- Set the top, trailing, bottom and leading constraints.
- Add a UIView to the UIScrollView.
- Set zero point constraints for your top, trailing, bottom and leading constraints.
2. Horizontal or Vertical Scrolling?
Horizontal Scrolling
- Add a WIDTH constraint to the UIView with a number that is wider than the main view's width.
- Right-click drag from the UIView to the main view and set constraint: Equal Heights
(Note that you want to scroll sideways so the height will not be changing.)
Vertical Scrolling
- Add a HEIGHT constraint to the UIView with a number that is longer than the main view's height.
- Right-click drag from the UIView to the main view and set constraint: Equal Widths
3. Setup Storyboard
- Select your Scene (ViewController)
- In the Size Inspector, change Simulated Size from Fixed to Freeform.
- Change the Width or Height to whatever you set in the previous step.
(Xcode 8)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.