UILable 设置最大右边距离,满足排列超出frame

2021-01-22  本文已影响0人  就用帅气点的昵称吧

[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {

make.left.equalTo(_delBtn.mas_right).offset(10);

make.right.mas_lessThanOrEqualTo(_selectImageView.mas_left).offset(-5);//最大右边距

make.height.mas_offset(16);

make.centerY.mas_equalTo(self);

        }];

注意设置了最大或者最小值必须设置优先级:

    [_titleLabel setContentHuggingPriority:240 forAxis:UILayoutConstraintAxisHorizontal];

    [_titleLabel setContentCompressionResistancePriority:720 forAxis:UILayoutConstraintAxisHorizontal];

//优先显示zanLabel

    [self.zanLabel setContentHuggingPriority:245 forAxis:UILayoutConstraintAxisHorizontal];

    [self.zanLabel setContentCompressionResistancePriority:725 forAxis:UILayoutConstraintAxisHorizontal];

上一篇下一篇

猜你喜欢

热点阅读