原理:

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. Velocity高速新手教程

    变量 (1)变量的定义: #set($name = "hello")      说明:velocity中变量是弱类型的. 当使用#set 指令时,括在双引號中的字面字符串将解析和又 ...

  2. Hdu2111

    <span style="color:#6600cc;">/* J - Saving HDU Time Limit:1000MS Memory Limit:32768K ...

  3. Android实战简易教程-第四十五枪(SlideSwitch-好看又有用的开关button)

    开关button也是在项目中经经常使用到的控件,github上有开源的项目,我们研究下它的用法: 1.SlideButton.java: /* * Copyright (C) 2015 Quinn C ...

  4. Apple Swift学习教程

    翻译自苹果的官方文档:The Swift Programming Language. 简单介绍 今天凌晨Apple刚刚公布了Swift编程语言,本文从其公布的书籍<The Swift Progr ...

  5. 使用Hibernate防止SQL注入的方法

    之前写代码,往后台传入一个组织好的String类型的Hql或者Sql语句,去执行. 这样其实是很蠢的一种做法!!!! 举个栗子~~ 我们模仿一下用户登录的场景: 常见的做法是将前台获取到的用户名和密码 ...

  6. text recognizer (OCR) Engine 光学字符识别

    https://github.com/tesseract-ocr/tesseract/wiki https://github.com/UB-Mannheim/tesseract/wiki C:\Use ...

  7. 记录一下收集到的clojure相关的东东

    https://github.com/plexus/chestnut 一个用来调试clojurescript的工具,解决 Clojure, ClojureScript, and CSS的reload问 ...

  8. Android系统定制----删除系统锁屏功能【转】

    本文转载自:http://blog.csdn.net/morixinguan/article/details/56675914 frameworks/base/packages/SettingsPro ...

  9. ubutu14.04无法使用sudo,也无法切换到root用户去解决问题怎么办?

    一不小心,修改了/etc/sudoers文件. 惨了. 无法使用sudo了,啥都干不成了. 最最关键的是,也无法用root登录. 本想着要重装系统了. 后来发现了神奇的ubuntu安全模式. 1.重启 ...

  10. ubuntu 截图工具 Shutter,设置快捷键 Ctrl+Alt+A

    系统设置 键盘 快捷键 自定义快捷键