Ios-visual Format Language

Source: Internet
Author: User

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

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.