IOS开发笔记 | 并排的两个label如何优先让其中一个宽度自
![](https://img.haomeiwen.com/i16040229/b9c45e775ae20a0a.png)
image.png
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarView.mas_right).offset(12);
make.top.mas_equalTo(self.top).mas_offset(16);
make.right.mas_lessThanOrEqualTo(self.timeLabel.mas_left).offset(-8);
}];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.top).mas_offset(16);
make.right.mas_lessThanOrEqualTo(self.mas_right).offset(-12);
}];
[self.nickLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
[self.nickLabel setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
[self.timeLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[self.timeLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
参考链接:https://www.jianshu.com/p/de470dca664a
本文标题:IOS开发笔记 | 并排的两个label如何优先让其中一个宽度自
本文链接:https://www.haomeiwen.com/subject/rnfdjrtx.html
网友评论