Swift&AutoLayout
来源:互联网 发布:mac版bt下载软件 编辑:程序博客网 时间:2024/06/07 05:26
let logoView = UIImageView(image: UIImage(named: "logo"))logoView.translatesAutoresizingMaskIntoConstraints = false//这句话一定要设置,否则自动布局无效,而且需要设置在需要设置布局的控件上,而不是controller的Viewview.addSubview(logoView)//布局原理即是:A(控件A)=B(控件B)*X(一定比例系数)+C(常量)view.addConstraint(NSLayoutConstraint(item: logoView,attribute: .top,relatedBy: .equal,toItem:playerView,attribute: .top,multiplier: 1,constant: 30))//上述代码的意思是:logoView.top = playerView.top * 1 + 30//此处约束是添加在父控件身上view.addConstraint(NSLayoutConstraint(item: logoView,attribute: .centerX,relatedBy: .equal,toItem: playerView,attribute: .centerX,multiplier: 1,constant: 0))//此处约束是添加在自己身上logoView.addConstraint(NSLayoutConstraint(item:logoView,attribute: .width,relatedBy: .equal, toItem: nil,//如果约束和其他控件无关,此处传nil attribute: .notAnAttribute, //此处传notAnAttribute multiplier: 0,//此处为0,因为没有作为参照的控件 constant: 100));logoView.addConstraint(NSLayoutConstraint(item:logoView,attribute: .height,relatedBy: .equal,toItem: nil,attribute: .notAnAttribute,multiplier: 0,constant: 100));
0 0
- Swift&AutoLayout
- Swift-AutoLayout system UITableViewCell
- AutoLayout Swift demo
- swift:autoLayout 中的默认规定
- IOS autolayout自动布局实例(swift)
- 开源 Swift AutoLayout 框架 SnapKit 介绍
- Swift基础(十二)UI基础--AutoLayout
- 开源 Swift AutoLayout 框架 SnapKit 介绍
- Swift autoLayout 下的UILabel 换行问题
- [iOS AutoLayout动画 坑] AutoLayout动画平移坑总结 => Swift/OC
- Swift自适应布局(Adaptive Layout)教程(一)Autolayout
- Swift自适应布局(Adaptive Layout)教程(二)Autolayout
- 自动布局autolayout使用总结(源码含swift版本)
- OC和Swift纯代码进行Autolayout布局
- Autolayout
- autolayout
- AutoLayout
- autolayout
- 欢迎使用CSDN-markdown编辑器
- 国科大软件安全漏洞分析与发现第一次作业key1
- 集合框架
- android 非系统APP访问字符设备
- bootstrap的editTable实现方法
- Swift&AutoLayout
- Android 多权限动态申请的优化
- iframe
- 2017国际体验设计大会亮点抢先看!
- 2017年阿里巴巴内推实习电话面试2
- 笔记之Python网络数据采集
- Spring注解下使用定时器
- 原生实现响应式模态框
- 【Linux】Centos之安装Nginx及注意事项