Center two UIViews of different sizes horizontally

I have the following wireframe:

enter image description here

I need to add "Don't have an account yet? Register." To do this, I will have two different UILabels, one with "Don't have an account yet?" and the other with β€œSign Up,” so I can separate them separately.

My problem is that I don’t know how to focus on Superview on two different labels that have different sizes, and I grow if it is localized in a language where they occupy more space than English ...

So the questions will be: "How do I center two UILabels with different widths associated with this add-in?"

Thanks a lot!

+5
source share
2 answers

Here are the steps:

  • Take a view that contains both of your labels and make centerx for it.
  • Attached mark 1 with all sides with a higher degree of width restriction
  • and follow step 2 for label2.

Here is a visual presentation of this ...

enter image description here

+5
source

You have to put them in a UIView container, make it flexible in width (e.g.> = 10) and center it.

+6
source

All Articles