Chapter 15 introduction to auto Layout

Source: Internet
Author: User

Chapter 15 introduction to auto Layout

 

1. You do not define a view's alignment rectangle directly. You do not have enough information (screen size !) To do that. instead, you provide a set of constraints. taken together, these constraints allow the system to determine the layout attributes, and thus the alignment rectangle, for each view in the view hierarchy.

 

2. A constraint defines a specific relationship in a view hierarchy that can be used to determine a layout attribute for one or more views. for example, you might add a constraint like "the vertical space between these two views shoshould always be 8 points" or "these views must always have the same width. "A constraint can apse be used to give a view a fixed size, like" This view's height shoshould always be 44 points."

 

3. each constraint has priority level that is used to determine which constraint wins when more than one constraint conflicts. A priority is a value from 1 to 1000, where 1000 is a required constraint. by default, constraints are required, so all of the constraints that you have added are required. this means that the priority level wocould not help if you had conflicting. instead, auto layout wocould report an issue regarding unsatisfiable constraints. typically, you find the constraints that conflict and then either remove one (often, the culprit is an obvious accident) or reduce the priority level of a constraint to resolve the conflict but keep all the constraints in play.

 

4. viewdidlayoutsubviews gets called any time the view changes in size (for example, when the device is rotated) or when it is first presented on the screen.

Chapter 15 introduction to auto Layout

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.