Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build an Interactive Story App with Swift Creating the User Interface Programmatically Displaying the Story

Miguel Sousa
Miguel Sousa
6,872 Points

Where's the bottom constraint for storyLabel?

I don't understand why there's no necessity to add a bottom constraint for storyLabel. I thought all "sides" from views should be anchored to another view or to a parent view. In this video, we only have leading, top and trailing anchor for storyLabel.

Also, is there any difference between creating a Left/Right Anchor constraint to a Leading/Trailing Anchor constraint?

Hi Miguel,

Some views have intrinsic heights, UILabels are one of those views. Because a label 'knows' it's height, there is enough information to create an unambiguous layout. Usually an element requires 4 constraints; leading, trailing, top & bottom might be one way to constrain an element. An equally valid way might be leading, top, height & width. The important thing is that the layout in unambiguous - Autolayout evaluates all constraints to one and only one possible solution.

I think the leading, trailing accounts for multiple languages i.e. Arabic reads right to left, so in that case leading would be right and not left.

Hope that helps.

Happy coding!

Adam