#JuniorTipThread

Let& #39;s talk AutoLayout.

AutoLayout is one of those things that until it clicks, it& #39;s super hard. Once it clicks, though, there& #39;s many new concepts that just keep building on top of it...

For example, content hugging and compression resistance.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread">1/6
I fell into the classic trap where I& #39;d set up my UI, then if one item was bigger than the others, so I& #39;d just randomly move both content hugging and compression resistance until it behaved like I expected.

ngl, it took me a long time to understand it.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread">2/6
Yeah, doesn& #39;t matter if you& #39;re a senior, you& #39;re still prone to just wanting to get the thing done instead of learning. https://abs.twimg.com/emoji/v2/... draggable="false" alt="🤷🏻‍♂️" title="Achselzuckender Mann (heller Hautton)" aria-label="Emoji: Achselzuckender Mann (heller Hautton)">

Anyway, content hugging and compression resistance basically allow you to determine which of two objects is going to expand or contract if...

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread">3/6
... the constraints demand it. A picture is worth a thousand words.

For example, what if you want your blue label to expand and the green label to contract? That& #39;s what content hugging and compression priorities are all about.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread">4/6
To explain it, here& #39;s this great article by Abhimuralidharan, which could be a really long name, a really long username or both. Names are hard.

https://abhimuralidharan.medium.com/ios-content-hugging-and-content-compression-resistance-priorities-476fb5828ef

Don& #39;t">https://abhimuralidharan.medium.com/ios-conte... be lazy like me. Read the article, understand both concepts and save yourself a lot of time.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread">5/6
This thread was also published in my latest newsletter! If you liked it, click here to join https://abs.twimg.com/emoji/v2/... draggable="false" alt="👀" title="Augen" aria-label="Emoji: Augen">

It helps since I& #39;m trying to do this full time https://abs.twimg.com/emoji/v2/... draggable="false" alt="🙌🏻" title="Erhobene Hände (heller Hautton)" aria-label="Emoji: Erhobene Hände (heller Hautton)">

https://mailchi.mp/hey/weekly-swift-exercise-signup

I">https://mailchi.mp/hey/weekl... also send weekly Swift exercises for beginners and intermediate learners alike!

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread">6/6
You can follow @fromjrtosr.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: