Appendix
4469 ワード
Visual Format Language
この付録では、AutoLayout Visual Format言語を使用して一般的な制約を最適化する方法について説明します.この付録には、標準の余白と次元、垂直レイアウト、およびその他のプロパティの制約が含まれています.また、この付録には完全な言語文法が含まれています.
Visual Format Syntax
次の例は、Visual Formatを使用して具体化できる制約です.テキストが画像と視覚的にどのように一致するかに注意してください.
標準余白
[button]-[textField]

幅の制限
[button(>=50)]

スーパービューに接続
|-50-[purpleBox]-50-|

垂直レイアウト
V:[topField]-10-[bottomField]

ビューのリフレッシュ
[maroonView][blueView]

優先度
[button(100@20)]

等幅
[button1(==button2)]

多述語
[flexibleButton(>=70,<=100)]

レイアウト内の完全な直線
|-[find]-[findNext]-[findField(>=20)]-|

シンボルは、表現の完全性よりも可視化される傾向があります.実際のUIでは、ほとんどの有用な制約をVisual Format Syntaxで表すことができます.しかし、いくつかの点がそうではありません.1つの表現不可能な有用な制約は、固定aspectratio(例えば
imageView.width = 2 * imageView.height)
)である.これらのコンストレイントを作成するには、constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:
を使用する必要があります.Visual Format String Grammar
Visual Format String構文は次のように定義されています(文字はコードフォントとして表示され、eは空の文字列を表します).
NOTE
objectOfPredicate
が生成される場合、viewName
は、述語の主題がビューの幅または高さである場合にのみ受け入れられる.すなわち、view1
およびview2
は、同じ幅を達成するために[view1(==view2)]
を使用することができる.構文エラーが発生すると、診断メッセージに例外が放出されます.例:
Expected ':' after 'V' to specify vertical arrangement
V|[backgroundBox]|
^
A predicate on a view's thickness must end with ')' and the view must end with ']'
|[whiteBox1][blackBox4(blackWidth][redBox]|
^
Unable to find view with name blackBox
|[whiteBox2][blackBox]
^
Unknown relation. Must be ==, >=, or <=
V:|[blackBox4(>30)]|
^
Reference
この問題について(Appendix), 我々は、より多くの情報をここで見つけました https://velog.io/@panther222128/Appendixテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol