iosxcodebuttonconstraintssizing

How do i create a constraint for my button, so it wont mess up the size of it


i have a button i want to have the same distance from screen edge on all devices, i put a constraint on right which works nicely but on bottom it messed up the size of my button. I tried making it bigger with the same constraint but it gives me warnings saying the size will be different at run time.

before i put the bottom (y) constraint

after the y constraint is added

with two constrains and after i stretch out resulting in misplaced view warnings


Solution

  • Make sure you also have a constraint from the leading side of the button to the left side of the screen with a constant of 0. Then, add a horizontal constraint.