0

Now I have 2 UILabels, their total width is fixed, and I wanna place them side by side, and make both of their text right-aligned. So I write(using masonry):

[self.authorLabel mas_makeConstraints:^(MASConstraintMaker *make){
    make.top.equalTo(self.abstractLabel.mas_bottom).offset(verticalInnerSpacing);
    make.bottom.equalTo(self.contentView.mas_bottom).offset(-bottomOffset);
    make.left.equalTo(self.dateLabel.mas_right);
    make.right.equalTo(self.contentView.mas_right).offset(-rightOffset);
}];

[self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make){
    make.top.equalTo(self.authorLabel.mas_top);
    make.bottom.equalTo(self.authorLabel.mas_bottom);
    make.left.equalTo(self.thumbImage.mas_right).offset(horizontalInnerSpacing);
    make.right.equalTo(self.authorLabel.mas_left);
}];

However the right label always have a width larger than its text size. What I wanna achieve is that the left label may have a blank space in front of its text, but the right label has a width depending on its text. What should I do then? In the two images, the first one is the current effect, the second one is the effect I want. Current effect My desired effect

Leo
  • 492
  • 1
  • 5
  • 15
  • http://stackoverflow.com/questions/12789013/ios-multi-line-uilabel-in-auto-layout – Muhammad Raheel Mateen Feb 24 '16 at 12:06
  • My question differs with that one, cause in my case, the right label has enough space, I just don't want it have that much space, I wanna it has the size depending on its text. – Leo Feb 24 '16 at 12:10

0 Answers0