您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页AutoLayout用 Masonry加属性写在什么地方

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

来源:二三娱乐

一般我是这么做的,

如果是在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);
    }];
    
}

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务