Reputation: 3052
I have two labels in the view and one of the labels can be changed by user input (adding numbers). The constraints are set programmatically and the horizontal constraints with visual format language look like this:
"H:|-11-[label1]-[label2(>=30@750)]-10-|"
The results looks like:
|[the text in label1...][label2]|
But when the user adds some numbers to label 2 it will look like:
|[the text in label1...][......]|
I've tried using updateConstraintsIfNeeded()
, updateConstraints()
and layoutIfNeeded()
but nothing is working.
This is the result I'm trying to get after inputting extra numbers:
|[the text in...][extra numbers]|
What am I doing wrong? Everything is programmatically coded.
Upvotes: 2
Views: 489
Reputation: 1092
Try doing this:
"H:|-11-[label1(<=70@750)]-[label2]-10-|"
You set up the low priority in the first label, because label2 is the one that you want to scale to fit the text
These are two images of my results
Before clicking in the Add button
After clicking in the Add button
Upvotes: 2