Problems getting the layout right in the Xcode

Asked

Viewed 300 times

0

I’m having difficulty with the following question. The blue button in the image below has to be at the height of the woman’s waist as it is on the storyboard, but it has to be on all iPhones (4" up). As can be seen in the preview, for each screen size the button gets different size and position. To hit this I have to use some specific Constraint (being q I’m using height, width, bottom margin, horizontal) or I have to hit this in the code?

Thank you.

iTela xcode

2 answers

2


As @danielbmarques said should work:

• Leading and trailing at the edges

inserir a descrição da imagem aqui

• vertical centered:

inserir a descrição da imagem aqui

• selects the Constraint and adjusts the Multiplier:

inserir a descrição da imagem aqui

• expected result:

inserir a descrição da imagem aqui

  • Thank you very much, very well explained. = D

1

Pro button stand with a proportional size, instead of creating constraints to size it, creates constraints pro Leading and trailing. So the edges of it will be at the same distance from the sides of the iPhone.

Pro vertical alignment stay proportional, instead of choosing a distance, place the button centered vertically, select the Constraint and play with the value of the "Multiplier" until the button is in the position you want.

Edit: Now that I’m thinking I don’t know if Leading and trailing will work... you can also put the width of the button equal to the width of the screen, and then stir the Multiplier of this Constraint to make the button larger or smaller.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.