NSLayoutConstraint 使用详解 VFL使用介绍
注意
使用前必须先取消所有的你想设置View 的 Autoresizing 属性 因为 Autoresizing Layout不能共存 系统默认是 Autoresizing
for v in subviews {
v.translatesAutoresizingMaskIntoConstraints=false
}
- 自动布局核心公式
view1.attr1 = view2.attr2 * multiplier + constant
- 自动布局构造函数
NSLayoutConstraint(item: 视图,
attribute: 约束属性,
relatedBy: 约束关系,
toItem: 参照视图,
attribute: 参照属性,
multiplier: 乘积,
constant: 约束数值)
如果指定
宽高约束- 参照视图设置为
nil - 参照属性选择
.NotAnAttribute
- 参照视图设置为
自动布局类函数
NSLayoutConstraint.constraintsWithVisualFormat(VLF公式,
options: [],
metrics: 约束数值字典 [String: 数值],
views: 视图字典 [String: 子视图])
VFL 可视化格式语言
H水平方向V垂直方向|边界[]包含控件的名称字符串,对应关系在views字典中定义()定义控件的宽/高,可以在metrics中指定
// icon布局 上下左右居中
addConstraint(NSLayoutConstraint(item: iconView, attribute: .centerX,
relatedBy: .equal,
toItem: self,
attribute: .centerX,
multiplier: 1.0,
constant: ))
addConstraint(NSLayoutConstraint(item: iconView, attribute: .centerY,
relatedBy: .equal,
toItem: self,
attribute: .centerY,
multiplier: 1.0,
constant: -)) maskiconView 和屏幕等宽 和屏幕顶部对齐 距离 loginBtn顶部 - 距离
let viewDic : [String : Any] = ["maskiconView":maskiconView,"loginBtn":loginBtn]
let metricDic = ["spacing":-] addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[maskiconView]-0-|",
options: [],
metrics: nil,
views: viewDic)) addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[maskiconView]-(spacing)-[loginBtn]",
options: [],
metrics: metricDic,
views: viewDic))
NSLayoutConstraint 使用详解 VFL使用介绍的更多相关文章
- Spring4.X + spring MVC + Mybatis3 零配置应用开发框架搭建详解(1) - 基本介绍
Spring4.X + spring MVC + Mybatis3 零配置应用开发框架搭建详解(1) - 基本介绍 spring集成 mybatis Spring4.x零配置框架搭建 两年前一直在做后 ...
- NSLayoutConstraint.constraintsWithVisualFormat详解,以及AlignAllCenterY
NSLayoutConstraint.constraintsWithVisualFormat详解,以及AlignAllCenterY 转载2015-07-08 18:02:02 鉴于苹果官方文档的解释 ...
- Solr系列三:solr索引详解(Schema介绍、字段定义详解、Schema API 介绍)
一.Schema介绍 1. Schema 是什么? Schema:模式,是集合/内核中字段的定义,让solr知道集合/内核包含哪些字段.字段的数据类型.字段该索引存储. 2. Schema 的定义方式 ...
- Spring-data-jpa详解,全方位介绍。
本篇进行Spring-data-jpa的介绍,几乎涵盖该框架的所有方面,在日常的开发当中,基本上能满足所有需求.这里不讲解JPA和Spring-data-jpa单独使用,所有的内容都是在和Spring ...
- C++11 并发指南六(atomic 类型详解一 atomic_flag 介绍)
C++11 并发指南已经写了 5 章,前五章重点介绍了多线程编程方面的内容,但大部分内容只涉及多线程.互斥量.条件变量和异步编程相关的 API,C++11 程序员完全可以不必知道这些 API 在底层是 ...
- 【原创】纯干货,Spring-data-jpa详解,全方位介绍。
本篇进行Spring-data-jpa的介绍,几乎涵盖该框架的所有方面,在日常的开发当中,基本上能满足所有需求.这里不讲解JPA和Spring-data-jpa单独使用,所有的内容都是在和Spring ...
- 纯干货,Spring-data-jpa详解,全方位介绍
本篇进行Spring-data-jpa的介绍,几乎涵盖该框架的所有方面,在日常的开发当中,基本上能满足所有需求.这里不讲解JPA和Spring-data-jpa单独使用,所有的内容都是在和Spring ...
- 【转帖】C# DllImport 系统调用使用详解 托管代码的介绍 EntryPoint的使用
1 DLLImport的使用 using System; using System.Runtime.InteropServices; //命名空间 class Example { //用Dl ...
- 【Android基础】Fragment 详解之Fragment介绍
Fragment在Android 3.0( API 11)引入,是为了支持在大屏上显示更加动态.灵活的UI,比如在平板和电视上.Fragment可以看作是嵌套的Activity,类似ActivityG ...
随机推荐
- Java SE之网络爬虫①
一 需求描述 给一个url,将该url对应网页内的所有的链接查找出来,并补充完整为绝对路径 简易版 /** * * @author Zen Johnny * @date 2018年4月29日 下午11 ...
- Viterbi
把语音分割为计算发音质量测度所需要的小单元时候,需要进行Viterbi对齐 Viterbi,在htk和sphinx中,也被称作token passing model Viterbi解码图是 状态数Sm ...
- javaweb简单的实现文件下载
public HttpServletResponse download(HttpServletRequest request, HttpServletResponse response) throws ...
- 高程小tips
1.DOM操作往往是JS程序中开销最大的部分,应尽量减少DOM操作.-P285 P297例子 2.元素的classList属性: 元素的classLis即该元素的class的值的集合,是一个列表(数 ...
- proxysql 系列 ~ 读写分离核心功能
一 相关表介绍 1 mysql_user 列表配置 1 username && password 账号密码 2 default_hostgroup 默认的组ID2 mysq ...
- IDEA 启动时 自定义配置-只是看一下而已--注册激活
可以看到很多东西,比如 :Application Server 都这么类型 ============ ===== 2017年11月10日14:25:30 原来是这样注册的,号称最简单的 2017年11 ...
- 海洋cms v6.53 v6.54版本漏洞复现
海洋cms v6.53 v6.54版本漏洞复现 参考链接: 今天发现freebuf上一篇海洋cms的漏洞,来复现一下. http://www.freebuf.com/vuls/150042.html ...
- Javascript - ExtJs - 组件 - 分页
服务端只需要返回如下格式的字符串,ExtJs就可以解析并自动生成分页数据. , name: "sam" } ] } 准备: CREATE PROCEDURE [dbo]. ...
- Hadoop Steaming开发之WordCount
简单的WordCount栗子--类似于编程语言中的hello world 1.shell脚本run.sh HADOOP_CMD="/usr/local/src/hadoop-1.2.1/bi ...
- Java类锁和对象锁
一.类锁和对象锁 二.使用注意 三.参考资料 一.类锁和对象锁 类锁:在代码中的方法上加了static和synchronized的锁,或者synchronized(xxx.class) 对象锁:在代码 ...