Masonry
是一个轻量级的布局框架, 拥有自己的描述语法, 采用更优雅的链式语法封装自动布局 简洁明了 并具有高可读性。
下面总结了平时不常见的使用方法来深入认识一下Masonry
什么时候用Mas_
//以下两者完全一样
![](https://img.haomeiwen.com/i14416289/f3717fcbe1e41caf.png)
By default, macros which support autoboxing are prefixed with mas_.
Unprefixed versions are available by defining MAS_SHORTHAND_GLOBALS before importing Masonry.
Learn to prioritize
![](https://img.haomeiwen.com/i14416289/1762572e98e9d914.png)
//2. mas_updateConstraints
Alternatively if you are only updating the constant value of the constraint you can use the convience method mas_updateConstraints instead of mas_makeConstraints
// this is Apple's recommended place for adding/updating constraints
// this method can get called multiple times in response to setNeedsUpdateConstraints
// which can be called by UIKit internally or in your code if you need to trigger an update to your constraints
![](https://img.haomeiwen.com/i14416289/5c24f5847524cfd8.png)
如何使用
![](https://img.haomeiwen.com/i14416289/b486fc32e23f7759.png)
网友评论