Visual Format Language
Visual Format Syntax
The following are examples of constraints you can specify using the visual format. Note how the text visually matches the image.
[button]-[textField]
[button(>=50)]
|-50-[orchidBox]-50-|
V:[topField]-10-[bottomField]
[maroonView][oceanView]
[button(100@20)]
[button1(==button2)]
[flexibleButton(>=70,<=100)]
|-[find]-[findNext]-[findField(>=20)]-|
The notation prefers good visualization over completeness of expressibility. There are constraints that cannot be expressed in visual format syntax, although most of the constraints that are useful in real user interfaces can be. 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 useconstraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:
.
Visual Format String Grammar
The visual format string grammar is defined as follows (literals are shown in code font
; e denotes the empty string).
<visualFormatString> |
(<orientation>:)? (<superview><connection>)? <view>(<connection><view>)* (<connection><superview>)? |
<orientation> |
|
<superview> |
|
<view> |
|
<connection> |
e| |
<predicateList> |
<simplePredicate>|<predicateListWithParens> |
<simplePredicate> |
<metricName>|<positiveNumber> |
<predicateListWithParens> |
|
<predicate> |
(<relation>)?(<objectOfPredicate>)( |
<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 |
<metricName> |
Parsed as a C identifier. This must be a key mapping to an instance of |
<number> |
As parsed by |
Note: For the objectOfPredicate
production, a viewName
is only acceptable 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:
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)]| |
^ |
相关推荐
iOS8开发~UI布局(二)storyboard中autolayout和size class的使用详解
代码实现的AutoLayout,简单的使用了VFL。
使用纯代码编写的iOS中UIScrollView用autolayout布局适配不同屏幕
iOS Autolayout PDF Ebook
ios autolayout tableview
英文版的autolayout指导教程,官方版
AutoAndroidLayout Android屏幕适配方案,直接填写设计图上的像素尺寸即可
参见: http://www.raywenderlich.com/50319/beginning-auto-layout-tutorial-in-ios-7-part-2
- iOS App 6.3 - AutoLayout 6.4 - iOS App 6.5 - iOS 6.6 - 6.7 - Git 6.8 - 6.9 - 6.10 - 6.11 - 6.12 - 6.13 Product ReDesign 7 - 7.1 - CocoaPods 7.2 - Crashlystics 7.3 - 7.4 Product Market 8 - 8.1 - 8.2...
官方版本,亲测可用
Dice-AutoLayout-iOS13-Bootcamp
本程序主要实现的功能是使用VFL语言实现屏幕适配,纯代码的方式,Autolayout实现屏幕适配
Apple从iOS6加入了Auto Layout后开始就比较委婉的开始鼓励、建议开发者使用自适应布局,但是到目前为止,我感觉大多数开发者一直在回避这个问题,不管是不是由于历史原因造成的,至少他们在心底还坚守着固定布局的老...
官方版本,亲测可用
ios_autolayout_demo iOS AutoLayout 以编程方式: NSLayoutConstraint 和 。 NSLayoutConstraint 演示: :
最近在研究UITableViewCell高度的自适应,在网上找到了一个国内人员开发的工具类,自己下载下来研究了一下,感觉非常不错,用起来也非常方便,这是高手的博客地址...用这个之前要会使用AutoLayout
对iOS里AutoLayout的深入理解和剖析
一行代码搞定自动布局!用最简单易用的Autolayout库。 实现 cell 和 tableview 高度自适应。
这是一份ios自动布局的文件,我是找了很久才找到的,学习这个自动布局其实是相当容易的
简单使用: PlaceholderTextView *textView = [[PlaceholderTextView alloc]init]; textView.placeholderLabel.font = [UIFont systemFontOfSize:15]; textView.placeholder = @"请输入文字...";...