LoginSignup
2
2

More than 5 years have passed since last update.

UIScrollViewのAutoLayout設定してみた

Last updated at Posted at 2016-07-20

Development Environment

  • OS X El Captain 10.11.2
  • Xcode Version 7.3.1

Language

Swift

Process

Step 1: Add Scroll View and View from the object library
スクリーンショット 2016-07-20 13.56.24(2).png

Step 2: Tap to select Scroll View and then tap Pin where Auto-Layout setting appears. After that, set Auto layout like following figure.
※Please make sure that remove check mark on "Constrain to margins" and border surrounding the white box turns to be red colour. Then, press "Add 4 Constraints" to confirm your setting.
スクリーンショット 2016-07-20 14.04.59(2).png

Step 3: Exactly do the same setting as Step 2 to View under Scroll View. Tap to select View under Scroll View and then tap Pin where Auto-Layout setting appears. After that, set Auto layout like following figure.
※Please make sure that remove check mark on "Constrain to margins" and border surrounding the white box turns to be red colour. Then, press "Add 4 Constraints" to confirm your setting.
スクリーンショット 2016-07-20 14.17.37(2).png

Step 4: Select View under Scroll View and press control key and drag to "View". After that, select Equal Widths and Equal Height like following gif image.
1gif.gif

Step 5: Change the priority of Height from Step 4. Change it from 1000 to 250 like following gif image.
※If your Scroll View size is not the same as View, warning still appears and you have to go Step 6 to fix. If the size is same, warning will disappear and finally finish setting Auto-Layout of Scroll View. Congrats!
スクリーンショット 2016-07-21 10.16.33(2).png

(Optional)Step 6: If the size of Scroll View is not the same as View Size, warning will appear. Tap yellow warning icon to fix constraint like following gif image. Then, done with Auto-Layout of Scroll View.
3gif.gif

やったー!!!!!!

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2