2022-03-16(Masonfy自动布局抗压缩设置)

需求:要求标题过长时压缩标题,保证在线人数一定是完全展示的

图片.png
    [self.roomNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.inset(10);
        make.leading.inset(10);
        make.height.mas_equalTo(20);
    }];
    
    [self.onlineNumIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(4);
        make.centerY.equalTo(self.roomNameLab);
        make.leading.equalTo(self.roomNameLab.mas_trailing).offset(10);
    }];
    
    [self.onlineNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(16);
        make.centerY.equalTo(self.roomNameLab);
        make.leading.equalTo(self.onlineNumIcon.mas_trailing).offset(2);
        make.trailing.inset(10);
    }];
    
    [self.roomNameLab setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
    [self.onlineNumLab setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

你可能感兴趣的:(2022-03-16(Masonfy自动布局抗压缩设置))