The basic use of the Automatic Layout of sizeclass and autolayout in iOS 8 is autolayoutsizeclass.

Source: Internet
Author: User

The basic use of the Automatic Layout of sizeclass and autolayout in iOS 8 is autolayoutsizeclass.

1. First, create a new project and set rootviewcontroller (I will not talk about it here)

2. Check the following (because we use sizeClass below, select two ):

3. here I created a lable named View1. here we can see that the constraint of View1 is set to 0 on the distance and left, and the width and height are set to 200, similarly, you can set the distance between the right and the bottom constraints,

4. After the above work is complete, click the Add button and a yellow constraint range will appear, for example:

 

5. Click Update Frames after completing the preceding work. The constraint of View1 is created ,. When we want to change the constraint, we need to first Clear the original constraint, Click Clear Constraints, and add the constraint again.

6. at this time, I created a lable named View2 and set the constraint to 8 (that is, 8 from View1), 8 from the right boundary, and 96 in height,

7. Click Add to Add constraints,

8. Update fream,

9. Similarly, if you create a lable for View3, you will not perform operations in each step to save everyone's time. At this point, the use of autolayout is basically completed and you can run it to see the effect.

 

Ii. Use of sizeclass

1. In the example above, we can find that wAny hAny is at the bottom. Click wAny. We can see that wAny hAny supports all Screen Settings. The disadvantage is that it is not exquisite, what should we do when we use a horizontal screen? (For detailed analysis of size class, refer to the Apple documentation ):

 

2. We need to adapt the screen to the horizontal screen, for example, select the following method:

3. Change attributes, set length and height. Here, I changed the height of View1, for example:

4. Change the height of View2 and View3 to match with View1, for example:

After the modification is complete, run the debugging, that is, the desired result. Of course, this example is just a simple understanding of the adaptation of the two screens. Likewise, you can adapt to other Apple screens.

I have limited knowledge and may not be able to refer to other documents or knowledge. I hope you will criticize and correct me.

 

Related Article

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.