///与下面约束对象属性截图相对应
//使用Auto Layout约束,禁止将Autoresizing Mask转换为约束
[self.funcView setTranslatesAutoresizingMaskIntoConstraints:NO];
/**
*@1.constraintWithItem:你想要约束的视图
*@2.attribute:约束的属性(枚举值,可使用com键查看)
*@3.relatedBy:与约束的父视图的关系(枚举值)
*@4.toItem:约束对象的父视图
*@5.attribute:约束的属性(枚举值,可使用com键查看),一般情况下与第二个参数写一样的
*@6.multiplier:相对于父视图的约束比例
*@7.constant:约束间隔
*/
//与约束视图与父视图宽度一致
NSLayoutConstraint *w = [NSLayoutConstraint constraintWithItem:_funcView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:_fview attribute:NSLayoutAttributeWidth multiplier:1 constant:0];
//与约束视图与父视图高度一致
NSLayoutConstraint *h = [NSLayoutConstraint constraintWithItem:_funcView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:_fview attribute:NSLayoutAttributeHeight multiplier:1 constant:0];
//与约束视图与父视图center.x一致
NSLayoutConstraint *x = [NSLayoutConstraint constraintWithItem:_funcView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:_fview attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
//与约束视图与父视图center.y一致
NSLayoutConstraint *y = [NSLayoutConstraint constraintWithItem:_funcView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_fview attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]; //把约束添加到父视图上
NSArray *array = @[w,h,x,y];
[_fview addConstraints:array];

 

最新文章

  1. 字符编码笔记:ASCII,Unicode和UTF-8
  2. Django入门
  3. SQL语言基础
  4. SqlServer 挂载本地盘符到服务器端,方面备份还原
  5. [开源夏令营][四] Docker remote API 之 镜像篇
  6. Unbuntu 14.04 下chrome browser bookmark 显示中文乱码解决方案
  7. Java生成目录
  8. [SOJ]连通性问题
  9. c++ new delete 常踩的坑
  10. Android Stuido 提高开发效率的插件
  11. js监听浏览器离开页面操作
  12. shell for 循环
  13. 一个时代的终结:为什么是时候放弃ITOM四大巨头了?这对IT领导者来说意味着什么?
  14. Java+selenium 如何下拉移动滚动条【实战】
  15. Linux系统VIM编辑器管理(2)
  16. Android导入AS工程
  17. Shell中的case命令
  18. 三、synchronized同步锁
  19. Linux命令-权限管理命令:chmod
  20. PHP远程连接mysql

热门文章

  1. delphi sdk 函数个数知多少?
  2. 测试 Open Live Writer
  3. Valid Mountain Array LT941
  4. 基于tomcat的solr环境搭建(Linux)
  5. keepalived+nginx+tomcat+redis集群环境部署
  6. Redis (非关系型数据库) 数据类型 之 String类型
  7. Hibernate validator的一些额外特性
  8. 20 模块之 re subprocess
  9. Java的GUI设计小技巧
  10. swift -基础语法