Masonry之初体验
来源:互联网 发布:linux系统yum指令 编辑:程序博客网 时间:2024/06/08 16:22
纯代码适配
视图最基本适配方法介绍
注意:必须先把视图加到父视图再进行适配
注意:右边和底部偏移量为负数
- 距离父视图 上下左右 各10个单位
UIView *backGroudView = [[UIView alloc] init]; backGroudView.backgroundColor = [UIColor orangeColor]; [self addSubview:backGroudView]; [backGroudView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(weakSelf.view).offset(10); make.left.equalTo(weakSelf.view).offset(10); make.bottom.equalTo(weakSelf.view).offset(-10); make.right.equalTo(weakSelf.view).offset(-10); }];
- 视图靠左上角,宽高固定100
UIView *backGroudView = [[UIView alloc] init]; backGroudView.backgroundColor = [UIColor orangeColor]; [self addSubview:backGroudView]; [backGroudView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(weakSelf.view).offset(10); make.left.equalTo(weakSelf.view).offset(10); make.width.mas_equalTo(100); make.height.mas_equalTo(100); }];
- 水平线居中,宽高固定
UIView *backGroudView = [[UIView alloc] init]; backGroudView.backgroundColor = [UIColor orangeColor]; [self addSubview:backGroudView]; [backGroudView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(weakSelf.view).offset(10); make.width.mas_equalTo(100); make.height.mas_equalTo(100); make.centerX.equalTo(weakSelf.view.mas_centerX); }];
- 垂直线居中,宽高固定
UIView *backGroudView = [[UIView alloc] init]; backGroudView.backgroundColor = [UIColor orangeColor]; [self addSubview:backGroudView]; [backGroudView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.view).offset(10); make.width.mas_equalTo(100); make.height.mas_equalTo(100); make.centerY.equalTo(weakSelf.view.mas_centerY); }];
- 相对父视图居中,宽高固定
//方法一UIView *backGroudView = [[UIView alloc] init]; backGroudView.backgroundColor = [UIColor orangeColor]; [self addSubview:backGroudView]; [backGroudView mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(100); make.height.mas_equalTo(100); make.centerY.equalTo(weakSelf.view.mas_centerY); make.centerX.equalTo(weakSelf.view.mas_centerX); }];//方法二UIView *backGroudView = [[UIView alloc] init]; backGroudView.backgroundColor = [UIColor orangeColor]; [self addSubview:backGroudView]; [backGroudView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(200, 200)); make.center.equalTo(weakSelf.view); }];
0 0
- Masonry之初体验
- Masonry初体验
- 浅谈Autolayout之Masonry
- AutoLayout 之 Masonry
- 自动布局之masonry
- 自动布局之Masonry
- Masonry学习之UILabel
- Masonry学习之UIScrollView
- Masonry学习之Array
- Statspack之初体验
- Vista之初体验
- MySQL之初体验
- 工作之初体验
- java之初体验
- Mondrian之初体验
- Statspack之初体验
- LR之初体验
- SOA 之初体验
- 海量数据处理面试题
- windows核心编程之服务(services)、函数(functions) 、例程(routines)
- 【收藏用】--切勿转载JAVA 使用Dom4j 解析XML
- PopuoWindow弹出时报BadTokenException的解决方案
- JavaScript基础篇(四)— — 函数
- Masonry之初体验
- DES加密算法
- hdoj1012
- undefined reference to 'socket@12'编译socket出错codeblocks
- 红黑树
- UIViewController之间的传值 6种
- ConcurrentHashMap原理分析
- LeeCode-Same Tree
- HTML标签不区分大小写