2

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.

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I was so focused on the second label, I thought I tried everything already... Read and googled so much stuff and it was all so simple...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.