About AutoLayout.
1. As far as possible with storyboard, add constraints convenient and intuitive.
2. Cannot be added with storyboard, consider Visual Format language build constraint
-Intuitive, easy to read, less code
3. Building constraints using Nslayoutattribute
-Easy to read, the code is too much TM
Here are a few examples of how visual Format Language
Visual Format language enables view positioning by setting the spacing between view and other view in the vertical (V) and horizontal (H) directions. Add the constraint with the following code,
+ (nsarray<nslayoutconstraint *> *) Constraintswithvisualformat: (NSString *) format options: ( Nslayoutformatoptions) OPTs metrics: (Nullable nsdictionary<nsstring *, NSNumber *> *) metrics views: (nsdictionary <nsstring *, id> *) views;
1. @ "V:|-10-[_headerl]-20-[_imagev (]-30-[_backbtn]-40-|)"
In the vertical direction, the distance between the _headerl and the upper edge of the Superview is 10,_headerl and _imagev spacing 20,_imagev height 200,_imagev and _backbtn 30,_ Backbtn and the lower edge of the Superview 40 apart
2:@ "[Button1 (==button2)]"
Button1 is equal to button2 width (no v or H, default h)
3: @ "[Button (>[email protected])]"
Button width >=100, priority 20
Ios-visual Format Language