原理:

1)约束生成;MASConstraintMaker;

2)缺省补齐:

- (void)setSecondViewAttribute:(id)secondViewAttribute {

if ([secondViewAttribute isKindOfClass:NSValue.class]) {

[self setLayoutConstantWithValue:secondViewAttribute];

} else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) {

_secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute];

} else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) {

_secondViewAttribute = secondViewAttribute;

} else {

NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute);

}

}

3)寻找约束添加视图,并添加

if (self.secondViewAttribute.view) {

MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view];

NSAssert(closestCommonSuperview,

@"couldn't find a common superview for %@ and %@",

self.firstViewAttribute.view, self.secondViewAttribute.view);

self.installedView = closestCommonSuperview;

} else if (self.firstViewAttribute.isSizeAttribute) {

self.installedView = self.firstViewAttribute.view;

} else {

self.installedView = self.firstViewAttribute.view.superview;

}

4)

(1)绝对尺寸信息添加到自身;

(2)绝对布局数据添加到父视图;

(3)参考系属性缺失补全为目标属性。

Masonry 原理与使用说明的更多相关文章

  1. Masonry 原理一

    Under the hood Auto Layout is a powerful and flexible way of organising and laying out your views. H ...

  2. drizzleDumper的原理分析和使用说明

    https://blog.csdn.net/qq1084283172/article/details/53561622 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog. ...

  3. 基于Angularjs实现分页

    前言 学习任何一门语言前肯定是有业务需求来驱动你去学习它,当然ng也不例外,在学习ng前我第一个想做的demo就是基于ng实现分页,除去基本的计算思路外就是使用指令封装成一个插件,在需要分页的列表页面 ...

  4. 【性能诊断】二、单功能场景的性能分析(fiddler、SQL Profiler)

    Fiddler fiddler是最强大最好用的Web调试工具之一,它能记录所有客户端和服务器的http和https请求,允许你监视,设置断点,甚至修改输入输出数据. 使用Fiddler无论对开发还是测 ...

  5. 黑色半透明镂空遮罩指引效果实现jQuery小插件

    /*! * by zhangxinxu(.com) 2017-05-18 * 新版上线时候的黑色半透明镂空遮罩指引效果实现jQuery小插件 * 兼容到IE8+ * MIT使用协议,使用时候保留版权 ...

  6. xenu简单介绍

    目录: 1.软件介绍 2.软件作用 3.功能特点 4.测试原理 5.使用说明 6.状态识别 工具下载链接:https://pan.baidu.com/s/1i4I9QK1 密码:lej7 1.软件介绍 ...

  7. 定时模块app_timer用法及常见问题—nRF5 SDK模块系列二

    app_timer是大家经常用到的一个库,app_timer的功能就是定时,也就是说,你在某一时刻启动一个app timer并设定超时时间,超时时间一到,app_timer就会回调timeout ha ...

  8. angularJS 自定义指令 分页

    原理和使用说明 1.插件源码主要基于angular directive来实现. 2.调用时关键地方是后台请求处理函数,也就是从后台取数据. 3.插件有两个关键参数currentPage.itemsPe ...

  9. Dubbo的反序列化安全问题-Hessian2

    0 前言 本篇是系列文章的第一篇,主要看看Dubbo使用反序列化协议Hessian2时,存在的安全问题.文章需要RPC.Dubbo.反序列化等前提知识点,推荐先阅读和体验Dubbo以及反序列化漏洞. ...

随机推荐

  1. rsh 无秘钥登陆配置

    /etc/hosts.equiv里的主机不须要提供password就能够訪问本机./etc/host.equiv 要和~/.rhosts文件连用. [root@web-htl2-01 ~]# cat ...

  2. Postgis经常使用函数

    1,基本操作函数 AddGeometryColumn(<schema_name>, <table_name>,<column_name>, <srid> ...

  3. cocos2d-x 3.6版连连看版本号控制

    为了以后的开发和管理.源代码开发必须要使用版本号控制.我们当然选择git来做版本号控制了. 假设你在终端输入git,提示不是一个命令的话.那就说明你的机器没有安装git工具.那就安装一个,百度之有非常 ...

  4. Mariadb 事务

    事务 事务具有ACID特性:原子性(A,atomicity).一致性(C,consistency).隔离性(I,isolation).持久性(D,durabulity). 1.原子性:事务内的所有操作 ...

  5. Mali GPU OpenGL ES 应用性能优化--基本方法

    1. 经常使用优化工具 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTXlBcnJvdw==/font/5a6L5L2T/fontsize/400/fil ...

  6. HDU 5752Sqrt Bo

    Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total S ...

  7. HDU 5855Less Time, More profit

    Less Time, More profit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/O ...

  8. C#与excel互操作的错误无法将类型为“Microsoft.Office.Interop.Excel.ApplicationClass”的 COM 对象强制

    C#与excel互操作的错误无法将类型为“Microsoft.Office.Interop.Excel.ApplicationClass”的 COM 对象强制 如果您使用的电脑要操作的是office2 ...

  9. 8-12 canvas专题-阶段练习一(上)

    8-12 canvas专题-阶段练习一(上) <!DOCTYPE html> <html lang="zh-cn"> <head> <me ...

  10. [NOI 2014] 起床困难综合征

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=3668 [算法] 从高位向低位贪心即可 时间复杂度 : O(30N) [代码] #in ...