iOS-布局-Masonry-优先级
1.Content Compression Resistance 百度翻译(内容压缩抗力)
2.Content Hugging 百度翻译(内容拥抱)
- Content Compression Resistance = 变大!(保持自己更大)
- Content Hugging = 抱紧!(保持自己更小)
UILayoutPriorityDefaultLow == 250;
UILayoutPriorityFittingSizeLevel == 50;
*/
UILayoutConstraintAxisVertical
*/
#import "ViewController.h"
#import "Masonry.h" @interface ViewController () @property(nonatomic,strong) UILabel * labelOne;
@property(nonatomic,strong) UILabel * labelTwo; @end @implementation ViewController - (void)initUI
{
[self.view addSubview:self.labelOne];
[self.labelOne mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view.mas_left).with.offset();
make.top.equalTo(self.view.mas_top).with.offset();
}]; [self.view addSubview:self.labelTwo];
[self.labelTwo mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_labelOne.mas_right);
make.right.equalTo(self.view.mas_right);
make.top.equalTo(self.view.mas_top).with.offset();
make.height.equalTo(_labelOne);
}]; [self.labelOne setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
/**参数一:(UILayoutPriority)
UILayoutPriorityRequired
UILayoutPriorityDefaultHigh
UILayoutPriorityDefaultLow
UILayoutPriorityFittingSizeLevel
*/ /**参数二:(UILayoutConstraintAxis)
UILayoutConstraintAxisHorizontal
UILayoutConstraintAxisVertical
*/
[self.labelTwo setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
}
- (void)viewDidLoad {
[super viewDidLoad]; [self initUI];
} - (UILabel *)labelOne
{
if (!_labelOne) {
self.labelOne = [[UILabel alloc] init];
self.labelOne.text = @"这是labelOne";
self.labelOne.backgroundColor = [UIColor redColor];
}
return _labelOne;
} - (UILabel *)labelTwo
{
if (!_labelTwo) {
self.labelTwo = [[UILabel alloc] init];
self.labelTwo.text = @"这是labelTwo";
self.labelTwo.backgroundColor = [UIColor greenColor];
}
return _labelTwo;
} @end
iOS-布局-Masonry-优先级的更多相关文章
- iOS开发-Masonry简易教程
关于iOS布局自动iPhone6之后就是AutoLayOut,AutoLayOut固然非常好用,不过有时候我们需要在页面手动进行页面布局,VFL算是一种选择,如果对VFL不是很熟悉可以参考iOS开发- ...
- iOS 自动布局 Autolayout 优先级的使用
一.约束的优先级 0.屏幕适配 发展历程 代码计算frame -> autoreszing(父控件和子控件的关系) -> autolayout(任何控件都可以产生关系) -> siz ...
- jQuery插件实现瀑布留布局masonry + infinitescroll 图片高度处理
jQuery插件实现瀑布留布局masonry + infinitescroll . 使用官方的示例代码实际测试发现,当上传到服务器的时候,由于图片下载速度问题,导致图片高度不能被正确识别,从而造成层的 ...
- iOS - 布局重绘机制相关方法的研究
iOS View布局重绘机制相关方法 布局 - (void)layoutSubviews - (void)layoutIfNeeded- (void)setNeedsLayout —————————— ...
- 第三方框架-纯代码布局:Masonry的简单使用
Masonry是一个对系统NSLayoutConstraint进行封装的第三方自动布局框架,采用链式编程的方式提供给开发者API.系统AutoLayout支持的操作,Masonry都支持,相比系统AP ...
- Xcode iOS布局autolayout和sizeclass的使用
一.关于自动布局(Autolayout) 在Xcode中,自动布局看似是一个很复杂的系统,在真正使用它之前,我也是这么认为的,不过事实并非如此. 我们知道,一款iOS应用,其主要UI组件是由一个个相对 ...
- iOS自动布局——Masonry详解
欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由鹅厂新鲜事儿发表于云+社区专栏 作者:oceanlong | 腾讯 移动客户端开发工程师 前言 UI布局是整个前端体系里不可或缺的一环 ...
- iOS 使用Masonry介绍与使用实践:快速上手Autolayout
介绍 Masonry 源码:https://github.com/Masonry/Masonry Masonry是一个轻量级的布局框架 拥有自己的描述语法 采用更优雅的链式语法封装自动布局 简洁明了 ...
- iOS - 布局NSLayoutConstraint动画的实现
抛出问题:为何在用到用到constraint的动画时以下代码无法实现动画的功能 ,没有动画直接刷新UI跳到80 - (void)touchesBegan:(NSSet<UITouch *> ...
- iOS:Masonry约束经验(19-03-21更)
1.label约束: 1).只需约束x.y 点相关就行.宽高 长度相关不用约束,就算用boundingRectWithSize计算出来的,也可能不准. 如:top.bottom二选一,trailing ...
随机推荐
- ES5 数组方法forEach
ES6已经到了非学不可的地步了,对于ES5都不太熟的我决定是时候学习ES5了. 1. js 数组循环遍历. 数组循环变量,最先想到的就是 for(var i=0;i<count;i++)这样的 ...
- Xiaomi 手机
- MongoDB副本集配置系列十:MongoDB local库详解和数据同步原理
1:local库是MongoDB的系统库,记录着时间戳和索引和复制集等信息 gechongrepl:PRIMARY> use local switched to db local gechong ...
- Codeforces Beta Round #17 C. Balance DP
C. Balance 题目链接 http://codeforces.com/contest/17/problem/C 题面 Nick likes strings very much, he likes ...
- Centos 7防火墙firewalld开放80端口
开启80端口 1.firewall-cmd --zone=public --add-port=80/tcp --permanent 出现success表明添加成功 命令含义: --zone #作用域 ...
- WP主题制作常用标签代码
WordPress模板结构 style.css : CSS文件index.php : 主页模板archive.php : Archive/Category模板404.php : Not Found 错 ...
- Windows Live Writer配置步骤
推荐文档: [超详细教程]使用Windows Live Writer 2012和Office Word 2013 发布文章到博客园全面总结 Live Writer 使用小贴示:发博客时始终使用图片原始 ...
- Oracle存储过程,以逗号分隔字符串传参的处理
Oracle存储过程,经常会遇见传入的参数是逗号分隔. 处理需要3步: 第一步,创建Type类型 第二部,创建函数 第三部,创建存储过程 代码如下: 第一步: create or replace ty ...
- VS2012文本编辑器鼠标不能滚动
- 基于soapUI构建WebService测试框架
基于soapUI构建WebService测试框架 http://www.docin.com/p-775523285.html