Search code examples
iosautolayoutconstraints

Buttons are not perfectly equally as expected iOS Autolayout


I'm trying to make "Two Equal-Width Buttons" As it's described in Apple Auto Layout Guide.

https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/ViewswithIntrinsicContentSize.html#//apple_ref/doc/uid/TP40010853-CH13-SW1

And it looks ok in preview of interface builder (Main.storyboard).But when I try to change devices i see that width is different on some devices. How can i fix that ? How can I make equal width of buttons for all devices by using constraints or another techniques?

Updated Examples:

width is ok

width is ok

width is not ok

width is not ok

Width is ok

Width is not ok


Solution

  • There is not problem with the width of your buttons. Because of difference of 0.5 point between two buttons, it may not be showing you equal width.

    Just check width of both button manually, there may not be difference between them, more than 1 point.

    Look at this snapshots:

    iPhone 5

    enter image description here

    iPhone 8

    enter image description here

    iPhone X

    enter image description here

    enter image description here

    enter image description here