ios - AutoLayout VisualFormatLanguage

Visual Format Language short cut in VFL

a. NSLayoutConstraint.constraintsWithVisualFormat("formatString", options:[NSLayoutFormatOptions], metrics:[String: NSNumber], views:[String: Anyobject]), this is the method we use in VFL, Let dive into the method.

b.the formatString: in this string we use characters like below:

|:stands for superview

-:standard value

V:vertical direction

H: horizontal direction

<= or >=: specify the value relationship

@:specify the priority

and the entire string is like:

"V:|-[componentToLayout([email protected])]-15-|" this is for vertical direction

"H:|-20-[componentToLayout([email protected])]-|"this is for horizontal direction

c.the NSLayoutFormatOptions is about to align the different components together, but remember when you in the Vertical direction you can only align the X axis alignment and when you in the Horizontal direction you can only align the Y axis alignment, final the alignment will be used to all components appear in the format string.

d.metrics: this is just a dictionary that used to declare the string used in the format string which stands for some NSNumber value, and we could use NSNumber value directly or constant even computed variable as the value referenced by the string key.

e.views: this is a dictionary that used to declare all the components used in format string like [component], is a type of [String: Anyobject], we use the key string to stands for the component related to the dictionary in the format string.

Sorry guys i‘m using a chinese blog website, so i have no idea if there is a blog i can use in english, please leave any comments below and the related chinese word is "评论",thank you so much for your reading, and if you have any suggestions please leave it below.

时间: 2024-08-04 05:00:55

ios - AutoLayout VisualFormatLanguage的相关文章

从此爱上iOS Autolayout

转:从此爱上iOS Autolayout 这篇不是autolayout教程,只是autolayout动员文章和经验之谈,在本文第五节友情链接和推荐中,我将附上足够大家熟练使用autolayout的教程.这篇文章两个月前就想写下来,但因为一直工作较多,没有时间来完成.今天终于狠下心,丢下代码不写,来完成他吧! 一.别和我提Autolayout,我想死!! 从iOS6/xcode4开始,苹果开始提供了autolayout——一种对不同屏幕尺寸有更好兼容的自动布局机制,但我相信大多数人在刚接触auto

iOS autoLayout总结

本文转自 http://ruikq.github.io/ios/autolayout/uiscrollview/2015/01/27/iOS-autolayout%E6%80%BB%E7%BB%93.html autolayout, and uiscrollview 以前学习iOS的时候没怎么接触过autoLayout,自从iPhone6个6+出来之后一直在为以前的app做适配,所以使用了大量的autoLayout做适配,一开始很不习惯,但是越用越觉得好用,接触到现在遇到很多问题,在这里总结一下

IOS AutoLayout详解(三)用代码实现(附Demo下载)

原创Blog,转载请注明出处 blog.csdn.net/hello_hwc 欢迎关注我的IOS SDK专栏,这个专栏我会持续进行更新. IOS SDK详解 前言: 在开发的过程中,有时候创建View没办法通过Storyboard来进行,又需要AutoLayout,这时候用代码创建就派上用场了,这篇文章我会详解用代码实现的两个主要函数,然后讲解一个Demo,最后Demo我会附上下载链接. 用代码实现的函数一 第一个函数通过描述两个view的参考线之间的约束来创建约束,例如有一个label和一个t

iOS — Autolayout之Masonry解读

前言 1 MagicNumber -> autoresizingMask -> autolayout 以上是纯手写代码所经历的关于页面布局的三个时期 在iphone1-iphone3gs时代 window的size固定为(320,480) 我们只需要简单计算一下相对位置就好了 在iphone4-iphone4s时代 苹果推出了retina屏 但是给了码农们非常大的福利:window的size不变 在iphone5-iphone5s时代 window的size变了(320,568) 这时auto

IOS Autolayout

●  Autolayout是一种"自动布局"技术,专门用来布局UI界面的 ●  Autolayout自iOS 6开始引入,由于Xcode 4的不给力,当时并没有得到很大推 广 ●  自iOS 7(Xcode 5)开始,Autolayout的开发效率得到很大的提升 ●  苹果官方也推荐开发者尽量使用Autolayout来布局UI界面 ●  Autolayout能很轻松地解决屏幕适配的问题 Autoresizing ● 在Autolayout之前,有Autoresizing可以作屏幕适配,

iOS.AutoLayout.2.CustomViewWithAutoLayout

Custom View Which Support AutoLayout 创建支持AutoLayout的Custom View AutoLayout 通过使view更加的自组织来减轻controller类的负担. 当实现custom view类时,需要提供足够的信息来使AutoLayout系统能够正确计算和满足约束(Constraints). 1. 为Custom View指定 intrinsic size (内在的/固有的 size) "Leaf-level views, such as bu

IOS AutoLayout 代码实现约束—VFL

在autolayout下,尽管使用IB来拖放控件,但仍然避免不了用代码来创建控件,这是约束需要代码来实现. IOS 提供了两种添加约束的方法 第一种: +(instancetype)constraintWithItem:(id)view1 attribute:(NSLayoutAttribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(id)view2 attribute:(NSLayoutAttribute)attr2 multip

iOS AutoLayout自动布局中级开发教程(2)-初识autolayout

通过storyboard,我们初识一下autolayout的表现形式: 看下图,使用storyboard创建的两个控件视图: 上图中的四个圆角框内的距离值,就是约束; 比如上图的第二个视图,他的 约束是:  距离 view左边,右边界的距离,这样就确定了 宽度和水平方向上的位置,还有距离上面(第一个)视图的距离,还有高,这样就确定了 视图的高度和y轴的位置;这样就可以在一个二维空间(屏幕)中唯一的确定这个视图的位置了; 但是,需要注意的,在添加距离上一个视图下边界的约束时,第一个视图的位置一定要

iOS AutoLayout 及SizeClass 自动布局(一)

一.关于自动布局(Autolayout) 在Xcode中,自动布局看似是一个很复杂的系统,在真正使用它之前,我也是这么认为的,不过事实并非如此. 我们知道,一款iOS应用,其主要UI组件是由一个个相对独立的可视单元构成,这些可视单元有的主要负责向用户输出有用的信息,有些则负责信息的输入(交互),交互的过程中往往还伴随有动画的效果,已达到整个信息传递的连贯性以及用户体验的细腻感.可视单元,在实际开发中主要是view.button等,那么这些可视单元的关系由两个基本的关系构成:兄弟关系和父子关系,整