Wednesday, July 3, 2019 [Tweets] [Favorites]

UIStackView and NSStackView

Reda Lemeden:

The UIStackView class provides axis-specific properties to define the layout: distribution for the main axis, and alignment for the cross axis.

[…]

Unlike NSStackView, UIStackView doesn’t support gravity-based distribution. This solution works by defining gravity areas along the main axis, and placing arranged items in any of them. One obvious upside of this approach is the ability to have multiple alignment rules within the same axis. On the downside, it introduces unnecessary complexity for most use cases.

[…]

The automatic layout calculation that stack views do for us come with a performance cost. In most cases, it is negligible. But when stack views are nested more than two layers deep, the hit could become noticeable.

[…]

Stack views are a lot more versatile than they get credit for. Their API on iOS isn’t always the most self-explanatory, nor is it the most coherent, but once you overcome these hurdles, you can bend them to your will to achieve non-trivial feats — nothing short of a Michelin star chef boasting their plating prowess.

This is probably the best overview I’ve seen.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment