- (void)viewDidLoad
{
[super viewDidLoad];
objectiveLabel.text = objectstring;
objectiveLabel.lineBreakMode = UILineBreakModeWordWrap;
objectiveLabel.numberOfLines = 0;
[objectiveLabel sizeToFit];
vocabularyLabel.text = vocabularystring;
vocabularyLabel.lineBreakMode = UILineBreakModeWordWrap;
vocabularyLabel.numberOfLines = 0;
[vocabularyLabel sizeToFit];
}
Can Someone point me to the right direction on how to get Label 1 to push or move Label 2 instead of overlapping?
If you want to “push or move” a UILabel, you just set the frames accordingly. So look at
objectiveLabel.frame, add theobjectiveLabel.frame.origin.xplusobjectiveLabel.frame.size.width, and that’s the minimum of what you should setvocabularyLabel.frame.origin.xto. If you wantvocabularyLabelto adjust for the width of not only theobjectiveLabelframe width, but actually to tweak according to howobjectstringwill be rendered inobjectiveLabel, you calculate the size ofobjectiveLabel‘s width by:This won’t factor in the
minimumFontSizeof the labels, though. But if theminimumFontSizeis the same size as the font size, then you should be golden.