+(id)constraintWithItem:(id)view1 attribute:(NSLayoutAttribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(id)view2 attribute:(NSLayoutAttribute)attr2 multiplier:(CGFloat)multiplier constant:(CGFloat)c; * view1 :要约束的控件 * attr1 :约束的类型(作怎样的约束) * relation :与参照控件之间的关系 * view2 :参照的控件 * attr2 :约束的类型(作怎样的约束) * multiplier :乘数 * c :常量
- (void)addConstraint:(NSLayoutConstraint *)constraint; - (void)addConstraints:(NSArray *)constraints;
view.translatesAutoresizingMaskIntoConstraints = NO;
+ (NSArray *)constraintsWithVisualFormat:(NSString *)format options:(NSLayoutFormatOptions)opts metrics:(NSDictionary *)metrics views:(NSDictionary *)views; * format :VFL语句 * opts :约束类型 * metrics :VFL语句中用到的具体数值 * views :VFL语句中用到的控件
NSDictionaryOfVariableBindings(...)
// 只要添加了这个宏,就不用带mas_前缀 #define MAS_SHORTHAND
// 只要添加了这个宏,equalTo就等价于mas_equalTo数组
// 这个头文件必定要放在上面两个宏的后面code
```
// 这个方法只会添加新的约束 [view makeConstraints:^(MASConstraintMaker *make) { }]; // 这个方法会将之前的全部约束删掉,添加新的约束 [view remakeConstraints:^(MASConstraintMaker *make) { }]; // 这个方法将会覆盖之前的某些特定的约束 [view updateConstraints:^(MASConstraintMaker *make) { }];
1.尺寸:width\height\size 2.边界:left\leading\right\trailing\top\bottom 3.中心点:center\centerX\centerY 4.边界:edges