Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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