Visual Format String Grammar
Symbol
Replacement rule
<visualFormatString>
(<orientation>:)?(<superview><connection>)?<view>(<connection><view>)*(<connection><superview>)?
<orientation>
H|V
<superview>
|
<view>
[<viewName>(<predicateListWithParens>)?]
<connection>
e|-<predicateList>-|-
<predicateList>
<易做图Predicate>|<predicateListWithParens>
<易做图Predicate>
<metricName>|<positiveNumber>
<predicateListWithParens>
(<predicate>(,<predicate>)*)
<predicate>
(<relation>)?(<objectOfPredicate>)(@<priority>)?
<relation>
==|<=|>=
<objectOfPredicate>
<constant>|<viewName>(see note)
<priority>
<metricName>|<number>
<constant>
<metricName>|<number>
<viewName>
Parsed as a C identifier.
This must be a key mapping to an instance ofNSViewin the passedviews dictionary.
<metricName>
Parsed as a C identifier. This must be a key mapping to an instance ofNSNumberin the passed metrics dictionary.
<number>
As parsed bystrtod_l, with the C locale.
我们以 btn1 和btn2 为例子
[btn1]-[btn2] 这个 “-” 标准连接字符 ,表示相距标准距离,好像是 8
[btn1 (>= 10)] btn1 宽度至少为10
H:|-50 -[btn1]-30-| “H“表示水平,”|”表示父视图, 这说明 btn1 在水平方向距离父视图左边50 右边30
[btn1(==btn2)] btn1 和btn2 宽度相等
[btn1 (>= 10,<= 50)] btn1的宽度在10和50 之间
说下这个<view>
我们可以这样写
|-[btn1]-|
也可以这样
|- 50-[btn1]-|
也可以这样
|-(>=10,<=30) - [btn1 (>=30)] -(<=20)-|
补充:移动开发 , IOS ,