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 ...
随机推荐
- Alfred 使用简介
1.安装(不说了去 Google 吧) 2.基础快捷键:option+space 3.打开应用程序:Alfred 几乎是一切程序的入口,你再也不需要找妈妈要开始菜单了.用快捷键呼出Alfred,输入任 ...
- LICEcap – 灵活好用,GIF 屏幕录制工具
LICEcap – 灵活好用,GIF 屏幕录制工具 http://www.appinn.com/licecap/
- 一致性hash和solr千万级数据分布式搜索引擎中的应用
互联网创业中大部分人都是草根创业,这个时候没有强劲的服务器,也没有钱去买很昂贵的海量数据库.在这样严峻的条件下,一批又一批的创业者从创业中 获得成功,这个和当前的开源技术.海量数据架构有着必不可分的关 ...
- Speech两种使用方法
COM组件使用speech: public class Speach { private static Speach _Instance = null ; private SpeechLib.SpVo ...
- nginx 重写 rewrite 基础及实例
nginx rewrite 正则表达式匹配 大小写匹配 ~ 为区分大小写匹配 ~* 为不区分大小写匹配 !~和!~*分别为区分大小写不匹配及不区分大小写不匹配 文件及目录匹配 -f和!-f用来判断是否 ...
- Codeforces Round #382 (Div. 2) D. Taxes 哥德巴赫猜想
D. Taxes 题目链接 http://codeforces.com/contest/735/problem/D 题面 Mr. Funt now lives in a country with a ...
- First MarkDown Blog
#First MarkDown Blog ##Title1 ##Tiltle2
- 39. Volume Rendering Techniques
Milan Ikits University of Utah Joe Kniss University of Utah Aaron Lefohn University of California, D ...
- Eclipse远程调试HDP源代码
使用的是自己编译的HDP2.3.0的源代码编译的集群,此文介绍如何使用Eclipse远程调试Hadoop内核源代码,以调试namenode为例进行介绍. 在/usr/hdp/2.3.0.0-2557/ ...
- timer.scheduleAtFixedRate和timer.schedule的实验
基础代码: Calendar currentTime = Calendar.getInstance(); currentTime.setTime(new Date()); int currentH ...