Jonas Larsen
Jonas Larsen

Reputation: 378

Xcode, constraints in navigation bar

I have this navigation bar. In the bar I have a random name, it won't always be the same. However, as it is now a big space comes between the 2 labels.

Simulator

My guess would be to use some kind of constraints, but Im kinda new to xcode so Im not sure which.

Xcode

Upvotes: 0

Views: 391

Answers (1)

Hakikat Singh
Hakikat Singh

Reputation: 285

For the following output : enter image description here

I have used the following constraints :

  1. Select both the labels and set their constraints equal height and align them to vertical center.

  2. Select the first label align its vertical center to the navigation bar and give its leading constraint (as much space you want) and keep its trailing space to 0 (I have given trailing space as 5 to keep some space between the texts of both labels)with the second label.

  3. Your xcode will give warning for the trailing constraint of the second label. You must keep it as >= (greater than or equal) to the super view by giving your desired constant.

    For the first Label i.e. Jonas You constraints will look like this

enter image description here

Keep the text alignment of the second label to left

Upvotes: 1

Related Questions