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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Marcos Reboucas](https://secure.gravatar.com/avatar/d1a6f13d480a8e13d7aa4dba58e5d7b5?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Marcos Reboucas
12,890 PointsWouldn't be better to use a stackview?
Well I don't know if it's exactly the same thing but I've created this example in 2 minutes in Interface Builder without any line of code using a stackview with 4 UIViews inside, aligning the stackview to the centerX, pining it's top and bottom to the same distance from the top and bottom container margins and giving the 4 UIViews inside the same height and width.
1 Answer
![Martin Wildfeuer](https://secure.gravatar.com/avatar/1d8de1e8e193bb39539e624618de9c60?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Martin Wildfeuer
Courses Plus Student 11,071 PointsYou could do it in Interface builder. They are doing it in code, though, as an alternative. That's probably why this course is called "Auto Layout in Code" ;). That is a matter of preference, I have fought endless fights with other devs. Either approach has its pros and cons, I will not go into detail here. It's never a bad idea to know the programmatic and IB approach, though. Also keep in mind that UIStackView
is only available in iOS 9 and later. Many apps still support iOS 7, some of them even iOS 6 (yes, I am looking at you, WhatsApp).