Extend two buttons horizontally across all AutoLayout devices

I'm trying to have two buttons side by side that look correct on all devices, but no matter what restrictions I seem to add, I am having problems like this (one button more than the other):

enter image description here

Any ideas on what I'm doing wrong by adding restrictions? I do not use the code for this, I just do it through InterfaceBuilder in the Storyboard.

A set of restrictions:

Answer: leading space, lower space, height is: 45, button "Go to delete"

Delete: trailing space, lower space, 32: 9 ratio, height is: 45, leading to Btn answer

+6
source share
3 answers

If you select both buttons, go to Editor> Output> Width Equal. Then set the height, leading / trailing space, the space between the buttons and the bottom space.

+13
source

For me, add the following restrictions

  • The Reply button adds the leading space and lower space for viewing
  • Add Y center constraint to remove button
  • Then align the upper and lower space to remove the button, and add a close button to delete.
  • After that, click the "Delete" button to add the lower space and the final space.

I had similar operations on one of my views, please see this image for more information. Reply Button

Happy Codding :)

+3
source

You need to add a constraint for equal width, as well as remove the β€œ32: 9” ratio constraint, which currently sets the width of the β€œDelete” button without the width set for the β€œReply” button. This is what causes the problem.

If you still have leading and trailing edges attached to their respective sides of the container view and set the space between them to zero, then you should be good.

+2
source

Source: https://habr.com/ru/post/976989/


All Articles