How to Use UIScrollView (multiple contentviews) in AutoLayout)
This post demonstrates how to use UIScrollView in AutoLayout. The ScrollView also contains multiple subviews. In this example, I use three views with different background colors as the ContentView of ScrollView.
Code download: https://github.com/djsison/iOS-ScrollView-AutoLayout-MultipleContents
If you want to know the ScrollView with only one view, you can view
IOS: How to use UIScrollView with Auto Layout (PureAuto Layout)-Single Content View
This article uses the AutoLayout-only layout method. See the following connection:
Https://developer.apple.com/library/ios/technotes/tn2154/_index.html
First, I define the following view layers in the story board:
- View (view of UIViewController)
· Scroll View (UIScrollView)-dark gray
· Container View (UIView)-light gray
· Content1 (UIView)-red
· Content2 (UIView)-green
· Content3 (UIView)-blue
The layout shown in the Story Board is as follows:
Note the following before setting layout rules: