Constraints prescribed to make Name, Serial, and Value labels equal width not working


Following the book on Xcode 9.2, Swift 4. On page 228 the book says we need to make a tweak to ensure that the Name, Serial, and Value labels are the same width. It says “With the interface as is, the text fields do not align on their leading edge due to the difference in the widths of the labels. (The difference is not very noticeable in English, but it becomes more pronounced when localized into other languages.) To solve this, you will add leading edge constraints between the three text fields.”

I add the leading alignment constraints as the book prescribes and yet the widths of the labels are not equal. Name label is 45 pts, Serial is 43 pts, and Value is 42 pts.

It doesn’t make sense to me why leading alignment constraints would lead to equal widths for the labels. Wouldn’t additional constraints be required to ensure equal width of the labels?


What version of the Xcode the book you have was written for?

Make sure that they are compatible.


The book says:

This edition assumes that the reader is using Xcode 8.1 or later and running applications on an iOS 10 or later device.

I did a little experimentation and added trailing alignment constraints for the three labels as well and then they did have equal widths of 45 pts. Was the trailing alignment constraints actually required to ensure the equal widths and the book does in fact leave that out?


I don’t have the book but If I were you, I would read the Auto Layout Cookbook first.