# How to dynamically change UIStackView axis

DevFeed: [How to dynamically change UIStackView axis](<https://devfeed.tech/articles/how-to-dynamically-change-uistackview-axis-37165.md>)

Original publisher: [Read original article](<https://arkadiuszchmura.com/posts/how-to-dynamically-change-uistackview-axis/>)

Published: 2023-06-30T00:00:00Z

Content type: tutorial

Language: en

Sources: [Arkadiusz Chmura](<https://devfeed.tech/sources/arkadiusz-chmura.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [ui](<https://devfeed.tech/topics/ui.md>), [User Experience](<https://devfeed.tech/topics/user-experience.md>), [interface](<https://devfeed.tech/topics/interface.md>), [function](<https://devfeed.tech/topics/function.md>)

Tags: [how-to](<https://devfeed.tech/tags/how-to.md>), [interface](<https://devfeed.tech/tags/interface.md>), [ios](<https://devfeed.tech/tags/ios.md>), [ui](<https://devfeed.tech/tags/ui.md>), [user-experience](<https://devfeed.tech/tags/user-experience.md>)

## AI overview

A tutorial explains how to dynamically switch a UIStackView from horizontal to vertical when its arranged label and button no longer fit without compression. It uses layout changes and the view's layout method to compare the elements' required width with the available width.

## Source excerpt

Let's see how we can change the axis from horizontal to vertical once the elements no longer fit the screen properly.