zoukankan      html  css  js  c++  java
  • Visual Format Language

    https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html#//apple_ref/doc/uid/TP40010853-CH27-SW1

    Visual Format Language

    This appendix shows how to use the Auto Layout Visual Format Language to specify common constraints, including standard spacing and dimensions, vertical layout, and constraints with different priorities. In addition, this appendix contains a complete language grammar.

    Visual Format Syntax

    The following are examples of constraints you can specify using the visual format. Note how the text visually matches the image.

    Standard Space

    [button]-[textField]

    image: ../Art/standardSpace.png
    Width Constraint

    [button(>=50)]

    image: ../Art/widthConstraint.png
    Connection to Superview

    |-50-[purpleBox]-50-|

    image: ../Art/connectionToSuperview.png
    Vertical Layout

    V:[topField]-10-[bottomField]

    image: ../Art/verticalLayout.png
    Flush Views

    [maroonView][blueView]

    image: ../Art/flushViews.png
    Priority

    [button(100@20)]

    image: ../Art/priority.png
    Equal Widths

    [button1(==button2)]

    image: ../Art/equalWidths.png
    Multiple Predicates

    [flexibleButton(>=70,<=100)]

    image: ../Art/multiplePredicates.png
    A Complete Line of Layout

    |-[find]-[findNext]-[findField(>=20)]-|

    image: ../Art/completeLayout.png

    The notation prefers good visualization over completeness of expressibility. Most of the constraints that are useful in real user interfaces can be expressed using visual format syntax, but there are a few that cannot. One useful constraint that cannot be expressed is a fixed aspect ratio (for example, imageView.width = 2 * imageView.height). To create such a constraint, you must use constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:

    Visual Format String Grammar

    The visual format string grammar is defined as follows (literals are shown in code fonte denotes the empty string).

     

    Symbol

    Replacement rule

    <visualFormatString>

    (<orientation>:)?

    (<superview><connection>)?

    <view>(<connection><view>)*

    (<connection><superview>)?

    <orientation>

    H|V

    <superview> 

    |

    <view>

    [<viewName>(<predicateListWithParens>)?]

    <connection>

    e|-<predicateList>-|-

    <predicateList>

    <simplePredicate>|<predicateListWithParens>

    <simplePredicate>

    <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 of NSView in the passed views dictionary.

    <metricName>

    Parsed as a C identifier. This must be a key mapping to an instance of NSNumber in the passed metrics dictionary.

    <number>

    As parsed by strtod_l, with the C locale.

    NOTE

    For the objectOfPredicate production, viewName is acceptable only if the subject of the predicate is the width or height of a view. That is, you can use [view1(==view2)] to specify that view1 and view2 have the same width.

    If you make a syntactic mistake, an exception is thrown with a diagnostic message. For example:

    1. Expected ':' after 'V' to specify vertical arrangement
    2. V|[backgroundBox]|
    3. ^
    4. A predicate on a view's thickness must end with ')' and the view must end with ']'
    5. |[whiteBox1][blackBox4(blackWidth][redBox]|
    6. ^
    7. Unable to find view with name blackBox
    8. |[whiteBox2][blackBox]
    9. ^
    10. Unknown relation. Must be ==, >=, or <=
    11. V:|[blackBox4(>30)]|
    12. ^
  • 相关阅读:
    Caffe2(1)----Ubantu14.04安装
    ROS知识(16)----如何编译时自动链接同一个工作空间的其他包的头文件(包含message,srv,action自动生成的头文件)
    GIT(4)----免输入账号和密码方法
    faceNet编译问题
    Python知识(7)--最小二乘求解
    BeanShell用法汇总(部分摘抄至网络)
    web_custom_request和web_submit_data
    创建一个数组,然后随机输出一个数组的值
    lr常见问题
    通过ctrl+r快速启动程序
  • 原文地址:https://www.cnblogs.com/feng9exe/p/6648725.html
Copyright © 2011-2022 走看看