Automatic layout of Ios_scrollview

Source: Internet
Author: User

ScrollView's automatic layout is a little cumbersome, but it's also a regular one,

The following is a fixed practice for adding constraints to vertical sliding only ScrollView

1. Add a label to the view of the controller and name it anchor

2. Add a constraint to anchor: 0 (indicates the view of anchor and Controller)

3. Add a ScrollView

4. Add the same constraint to the ScrollView: 0(indicating that the ScrollView is also associated with the controller's view)

here ,scrollview two key constraints (2 constraints determine the horizontal and vertical scrolling range)

5. Add a label to ScrollView, named BG1 (you can directly determine the scroll range of the ScrollView by using the label)

6. Add a constraint to the BG1, bg1 to the right and left all 0, and a height of 35

Here are the key points :

At the same time check anchor and BG1, let them equal width equal width;

(Note: The goal is to make the horizontal scrolling range of the ScrollView exactly the same as the screen width, i.e. the horizontal direction is not scrollable)

BG1 from 999

(Note: The purpose is to determine the vertical scrolling range of the ScrollView, which can be adjusted arbitrarily , this constraint can also be added to the bottom of any scrollview in a child element)


Here is: Xib interface, if you do not understand the place can be presented below

Automatic layout of Ios_scrollview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.