mas

Masonry

2015-07-03  本文已影响452人  RuiL

主要属性

@property (nonatomic, strong, readonly) MASConstraint *left;//左侧
@property (nonatomic, strong, readonly) MASConstraint *top;//上侧
@property (nonatomic, strong, readonly) MASConstraint *right;//右侧
@property (nonatomic, strong, readonly) MASConstraint *bottom;//下侧
@property (nonatomic, strong, readonly) MASConstraint *leading;//首部
@property (nonatomic, strong, readonly) MASConstraint *trailing;//尾部
@property (nonatomic, strong, readonly) MASConstraint *width;//宽
@property (nonatomic, strong, readonly) MASConstraint *height;//高
@property (nonatomic, strong, readonly) MASConstraint *centerX;//横向中点
@property (nonatomic, strong, readonly) MASConstraint *centerY;//纵向中点
@property (nonatomic, strong, readonly) MASConstraint *baseline;//文本基线

术语解释

约束函数

添加大小约束(大小为100 *100)
make.size.mas_equalTo(CGSizeMake(100, 100));

居中约束
make.center.equalTo(weakSelf.view);

与左边界约束(本视图左侧与父视图边界相切为0)
make.left.equalTo(self.view).offset(0);

与其他控件宽度约束(本视图的宽度与其余两个视图宽度相等)
make.width.equalTo(@[topView,bottomView]);

设置两个控件之间的距离(顶部与上一个视图底部相距150)
make.top.mas_equalTo(topView.mas_bottom).offset(150);

与左、下均相切
make.left.bottom.equalTo(self.view).offset(0);

设置宽和高的约束(均为150)
make.width.height.mas_equalTo(150);

设置两个控件关联(该控件与目标控件高度一致【纵坐标相等】)
make.centerY.mas_equalTo(imageView1);

上一篇下一篇

猜你喜欢

热点阅读