==========autolayout && Layout constraints===== (available 6.0)
--autolayout is a constraint-based, descriptive layout system. Auto layout is a constraint-based, descriptive layout System.
--How it works : Auto layout uses all of these constraints to do some math calculations on all your view so that the view achieves an ideal position and size. You no longer need to set the Frame-auto layout of the view to help you do all this-based on the constraints you set for view
--Idea: Design by Purpose . When you design by purpose, you are expressing what you want to achieve and not how to accomplish it. In the past it would be this: "The coordinates of the upper-left corner of this button are (20, 230)", and now you can say: "This button is centered vertically in its superview, placing him in a fixed position from the left edge of its superview." ”
--the difference with autosizing masks contact :
--autosizing masks is a subset of AutoLayout.
--1.autolayout can specify the relative position of any two view without needing two view in the immediate view hierarchy like Autoresizing mask.
--2.autolayout does not have to specify a constraint on an equality relationship, it can specify a non-equality constraint (greater than or less than, etc.), and the layout that autoresizing mask can make can only be of equal condition.
The--3.autolayout can specify the precedence of the constraint, and the calculation of the frame takes precedence over the condition that satisfies the high priority.
--Using autosizing Masks (xib):
--align:
(Can be set when selecting two view) Align left, align Right, top, bottom align,
-----------------------------------------------------------------------
(Can be set when two view is selected) x-axis center alignment, y-Axis center alignment, text bottom line alignment,
-----------------------------------------------------------------------
(Can be set when one view is selected) aligns to the center of the x axis of the parent view, aligned to the center of the y axis of the parent view
-----------------------------------------------------------------------
Update (frame) options: do nothing after adding a constraint + rearrange the view inside the container after you add the constraint after the view + add constraint is involved in the display
OK button: Click Add constraint after selecting the item above
--pin
The above cross is "bound to the nearest neighbor", fill in the numbers, click the dashed line to become a solid lines is to add this constraint.
The "neighbor" here is a parent view that contains a child view as a box with a pile of bricks, and the building blocks are "neighbors" relative to the box's borders and other bricks. quite editor->pin inside horizontal spacing/vertical Spacing with Leading/trailing/top/bottom Space to Superview combined .
-----------------------------------------------------------------------
(defined width-height data constraints): Width designation, height designation;
-----------------------------------------------------------------------
(Defines the width-height constraint between multiple view): same width, same height;
-----------------------------------------------------------------------
(list, alignment constraint between multiple view: equivalent to the contents of the previous menu;
-----------------------------------------------------------------------
Update (frame) option + OK button above.
--resolve Auto Layout Issues
(The action object of the top half menu is the currently selected view, the lower part of the action object is the view within the selected view)
--Refreshes the frame (using all constraints that are currently set),
--Refresh the constraint (update the constant value of the constraint based on the current constraint and frame),
--Add missing constraints (automatically add constraints that the system thinks you should add but forget to add, often conflicting in the test)
--Resets to system-recommended constraints (cleaning up the system's perceived duplication/conflict constraints, often making problems in testing)
--Clears all constraints (removes all constraints bound on the object)
--constraints settings
(which views are refreshed when constraints are added)
--Peer view and parent view
--Child View
====== notes ======
--0. When the constraints of a View is too small to calculate its location and size, Xcode warns (also called Root View's Layout issues). Resolve a root view ' layout issues by resolving the layout issues of its subviews. See the arrow at the top right of the dock (Choose Editor > Show Document Outline > Click the arrow next to the root view with the layout issues).
--1.auto layout can support different languages;
--2. Intrinsic size content : In Auto Layout, you will first ask how much space they have, and then show them to the screen based on the information given in the space. You can also not use it, but you have to explicitly set the width of this space or Height constraint. If you do, then Interface Builder automatically generates a constraint that you set. If you want to restore the intrinsic content size again, you only need to re-use size to Fit content
--3. Constraints and Constraints conflict, both Xib and Xib, Xib and Code, code, and code. When a view has too many constraints, get the error "unable to simultaneously satisfy constraints", indicating there is a conflict.
--4. The constraint conflict system is automatically resolved, usually relying on the right level, but because of the general situation cannot be used to determine what the right level of a constraint, it is difficult to set the right level to deal with the conflict.
--5. Constraint conflicts, IOS6 not seen on the crash, iOS7 on the occasional crash.
--6. There is a warning "Frame for" XX "would be different at run time." Its expected frame is just what you set in size inspector, actual is calculated according to the constraints you add, to resolve the warning only in the "Resolve Auto Layout issues" inside the frame to refresh, Speak of expected into actual.
[Nslayoutconstraint Constraintwithitem: (ID) item
Attribute: (Nslayoutattribute) attribute
Relatedby: (nslayoutrelation) relation
Toitem: (ID) otheritem
Attribute: (Nslayoutattribute) Otherattribute
Multiplier: (cgfloat) multiplier
Constant: (CGFloat) constant]
Parameter description:
First parameter: Specifies the view to the left of the constraint View1
The second parameter: Specifies the attribute attr1 of the View1, the specific property is at the end of the article.
The third parameter: Specifies the relationship between the left and right sides of the view relation, the specific relationship at the end of the article.
Fourth parameter: Specify the view to the right of the constraint View2
The fifth parameter: Specifies the attribute attr2 of the VIEW2, the specific property is at the end of the article.
Sixth parameter: Specifies a multiplier that multiplies the View2 property multiplier
Seventh parameter: Specifies a floating-point number that is added to the View2 property constant
The control formula for this function is:
VIEW1.ATTR1 <relation> view2.attr2 * multiplier + constant
Attention:
1. If the constraint you want to set does not require a second view, set the fourth parameter to nil and the fifth argument to Nslayoutattributenotanattribute
Example:
[Nslayoutconstraint Constraintwithitem:view1
Attribute:nslayoutattributeleft
Relatedby:nslayoutrelationequal
Toitem:view2
Attribute:nslayoutattributeright
Multiplier:1
CONSTANT:10]
The translation is: the left side of the View1, on the right side of the view2, more than 10 points, the place.
Values of properties and relationships attached to the view:
typedef ns_enum (Nsinteger, nslayoutrelation) {
Nslayoutrelationlessthanorequal =-1,//less than or equal
nslayoutrelationequal = 0,//equals
Nslayoutrelationgreaterthanorequal = 1,//greater than or equal
};
typedef ns_enum (Nsinteger, Nslayoutattribute) {
Nslayoutattributeleft = 1,//left
Nslayoutattributeright,//Right
Nslayoutattributetop,//above
Nslayoutattributebottom,//below
nslayoutattributeleading,//Header
Nslayoutattributetrailing,//tail
Nslayoutattributewidth,//width
Nslayoutattributeheight,//height
Nslayoutattributecenterx,//x Axis Center
Nslayoutattributecentery,//y Axis Center
Nslayoutattributebaseline,//text bottom marking
Nslayoutattributenotanattribute = 0//No attributes
};
IOS AutoLayout Parsing