AutoLayout用 Masonry加属性写在什么地方

2017-03-30  本文已影响30人  呆木大人

一般我是这么做的,

如果是在ViewController里面写,就直接卸载viewdidload里面

如果是在view里

-(void)updateConstraints
{
    [super updateConstraints];
    WeakObj(self);
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
        make.right.equalTo(@0);
    }];
    
    [self.upLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(selfWeak.mas_centerY).multipliedBy(0.6);
        make.centerX.equalTo(selfWeak.mas_centerX);
    }];
    
    [self.downLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(selfWeak.mas_centerX);
        make.centerY.equalTo(selfWeak.mas_centerY).multipliedBy(1.4);
    }];
    
}
上一篇下一篇

猜你喜欢

热点阅读