Autolayout ~

Source: Internet
Author: User

Previously, frame was set manually, or autoresizing was used,

However, with the release of iPhone 6 and 6 plus, autolayout is almost the best adaptation solution, with too many sizes of Linear Regression

Previously developed autolayout was disabled in the panel, so we can't do it now ~

 

First, let's see how to use autolayout in Ib. First, drag two uiviews and set the background color,

 

Select a view and click the following button.

 

A clear view of the function, relative to the top, bottom, left and right, so that when switching between the screen or different sizes, the view will automatically adapt

What is the maximum width and height?

After the conditions are set, click the Add constraint button to add constraints to the view. In this case, the view automatically adjusts its position and size.

 

There should be not many constraints given using autolayout,

What are not many? If you specify that the upper and lower sides of the view are 100 different from those of the parent view, you do not need to add other constraints to the view. If you limit the width of the view at the same time, there is a limit on redundancy.

Or you have added only the limit on width and height without adding other restrictions. In this case, the view only knows its width and height, but does not know its position. In this case, the constraints are missing.

If your restrictions are missing or redundant, IB will prompt you.

 

Click the red dot button indicated by the arrow in the middle to give suggestions for deleting or adding constraints (jump)

 

 

Click "little red dot" to display the restricted operation interface. add or delete constraints ~, However, you 'd better check it by yourself. The running of the province is not what you want.

 

The red box of is the added constraint. If you want to delete the constraint, click the delete key. If you want to modify the constraint, you can click it in the attribute panel on the right, set the background color and title with uibutton.

 

 

Autolayout ~

Related Keywords:

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.