Masonry
Masonry是一個輕量級的布局框架 擁有自己的描述語法 采用更優(yōu)雅的鏈式語法封裝自動布局 簡潔明了 并具有高可讀性 而且同時支持 iOS 和 Max OS X
Masonry是手動適配UI的一個不錯的方案,在Github上有對應(yīng)的Demo,學(xué)習(xí)成本也不大黎侈,可以作為手寫代碼適配的一個解決方案。例子中對常用的適配進行了舉例镇饮,例如
接下來簡單介紹一下
我們先來看code來認識一下Masonry
·```
[view1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(superview).with.insets(padding);
}];
* 看到block里面的那句話: make edges equalTo superview with insets
通過鏈式的自然語言 就把view1給autolayout好了 是不是簡單易懂?
#### 使用
看一下Masonry支持哪一些屬性
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/260268-d46ec790513c67f7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/260268-e5f8dc31e3fc0516.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
####栗子
* [基礎(chǔ)] *居中顯示一個view*
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/260268-7c0ed5a5dbd36eb8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/260268-51d4d128329672a4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
[適配Cell高度](https://github.com/thinklion)
[練習(xí)代碼](https://github.com/adad184/DemoMasonry)
[別人的博客總結(jié)](http://tutuge.me/2015/05/23/autolayout-example-with-masonry/)