Auto layout: A friend or a foe?

The first of the two parts

--

“Auto Layout, nah”… already some of you said that even from my title. I’m so excited to write about this topic because is one of my favourite. So what is Auto Layout? Why so many people are falling in love with it while some others really hate it and prefer to write an app without a Main.Storyboard file.

I’m the only one who designs the UI first on the paper and then on sketch? 🙈🤓

First things first. Auto Layout according to Apple:

Dynamically calculates the size and position of all the views in your view hierarchy, based on constraints placed on those views. For example, you can constrain a button so that it is horizontally centred with an Image view and so that the button’s top edge always remains 8 points below the image’s bottom. If the image view’s size or position changes, the button’s position automatically adjusts to match.

This constraint-based approach to design allows you to build user interfaces that dynamically respond to both internal and external changes.

It’s a really powerful tool and when someone fully understands it, it’s pretty much magic. With that said the list that follows are some of the advantages I found over the years.

It helps new developers

2 years ago as a new developer I had to learn Swift, how to write the language properly and so many other things such as extensions, closures and so on. I didn’t want to spent more time with coding the UI so I learned how Auto Layout works. I understood that If a new developer understands well this technology can save a lot of time in the development process.

Simple Layouts and Adaptivity

When it comes to simple layouts and the adaptivity of your app, Auto Layout is a great tool that you can use. Especially with Xcode 8 the team behind interface builder did an amazing job improving it. Works really great and it has some great features (Tips and tricks for interface builder are coming in the 2nd part so stay tuned)

It’s faster “to Auto Layout” than to code the UI

It’s not right or wrong way to create your User Interface in iOS development. For many users the Auto Layout works great and faster than the other one. I’m one of them. I think that it’s so fast to use Auto Layout than to set constraints programmatically.

Advanced Technology

Believe it or not, Auto Layout is an advanced technology that Apple is putting a lot of hard work into improving it and make it better. With every Xcode update I found that the updates that the Interface builder team made are really well executed.

Useful Conclusions

As a developer don’t ditch/use only one method when it comes to design your UI on Xcode. Both methods are having their advantages and disadvantages. Embrace them both.

If you are a newbie with Auto Layout, WWDC talks is a great start to understand how it works and learn some useful insights about it. More specifically when I started experimenting with Auto Layout WWDC was so good for me.

I hope that you enjoyed the read and that I gave a hint or a start to go and work with this really interesting technology. In the second part of this series I will share with you my favourite tips and tricks with Auto Layout. Until next time, have an awesome week and keep coding.

Agisilaos Tsaraboulidis is an iOS Developer & the maker of SoundMemory Rush.

f you enjoyed reading this entry, please hit the 💚 button

--

--

Tsaraboulidis Agisilaos
The adventures Of An iOS Developer

Co-Founder and CTO @irisapp. prev: iOS eng intern @Microsoft. Makes @soundmemoryrush. Photographer. I like traveling. Nerd. 22.