UIStackView; Equal Spacing Between & Outside Elements

房东的猫 提交于 2019-12-08 20:47:07

问题


UIStackView is awesome, I love Equal Spacing Distribution. But how to achieve the same space also outside of elements dynamically? In my case all elements will have same ratio 1:1


回答1:


You can add equal spacing using the story board as shown here:

Source: https://stackoverflow.com/a/32862693/3393964




回答2:


You can use constraints and give then same height and width. So when you change the dimension of anyone of the component then all components are changed with same dimension.




回答3:


I think what you want is to have the same spacing outside of the stack view with the spacing outside.

What I would do is the put stack view inside another view (GRAY VIEW) and set the leading and trailing constraint of the stack view to be equal to the spacing of the stack view.

Spacing of the Stack View

Constraints of the Stack View from its super view (Gray View)



来源:https://stackoverflow.com/questions/43045423/uistackview-equal-spacing-between-outside-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!