简单实用
http://www.jianshu.com/p/37ddbefc39d3
深入学习
http://www.jianshu.com/p/bccc447e10b8
Masonry的介绍
http://www.cocoachina.com/ios/20141219/10702.html
源码
https://github.com/SnapKit/Masonry
介绍Masonry基础使用,很详细
http://www.cnblogs.com/ios122/p/4826700.html
一个人的学习笔记,记录的很完善
http://www.cnblogs.com/wqcoder/p/5511676.html
ios9开发-autolayout
http://www.jianshu.com/p/5a05e06fa9e3
https://github.com/qiuncheng/Autolayout
NSLayoutContraint
学习心得:
Masonry相关
.equalToequivalent toNSLayoutRelationEqual
.lessThanOrEqualToequivalent toNSLayoutRelationLessThanOrEqual
.greaterThanOrEqualToequivalent toNSLayoutRelationGreaterThanOrEqual
*两个重要的宏
//define this constant if you want to use Masonry without the 'mas_' prefix
// 只要添加了这个宏,就不用带mas_前缀
#define MAS_SHORTHAND
//define this constant if you want to enable auto-boxing for default syntax
// 只要添加了这个宏,equalTo就等价于mas_equalTo
#define MAS_SHORTHAND_GLOBALS
mas_makeConstraints与makeConstraints
用mas_makeConstraints的那个view需要在addSubview之后才能用这个方法
mas_equalTo于equalTo
mas_equalTo适用数值元素,equalTo适合多属性的比如make.left.and.right.equalTo(self.view)
方法and和with只是为了可读性,返回自身,比如make.left.and.right.equalTo(self.view)和make.left.right.equalTo(self.view)是一样的。
2.让superview1略小于其superview(边距为20)
UIView *superview1 =[UIView new];superview1.backgroundColor = [UIColor redColor];[superview addSubview:superview1];[superview1 mas_makeConstraints:^(MASConstraintMaker *make) { // 写法一 make.edges.equalTo(superview).with.insets(UIEdgeInsetsMake(20, 20, 20, 20)); /** 写法二 make.top.equalTo(superview).with.offset(20); make.left.equalTo(superview).with.offset(20); make.bottom.equalTo(superview).with.offset(-20); make.right.equalTo(superview).with.offset(-20); **/ /** 写法三
make.top.left.bottom.and.right.equalTo(superview).with.insets(UIEdgeInsetsMake(20, 20, 20, 20)); **/}];
left/right 与 leading/trailing没有什么区别
https://yq.aliyun.com/articles/16436
3.Masonry设置完约束后,马上就回去frame的话,获取的frame是不对的,参考另外一篇文章。