How to center both vertical and horizontal inside a UIStackView

元气小坏坏 提交于 2019-12-04 07:13:59

Use two stack views.

Vertical stack view with centre alignment.

Inside that is a horizontal stack view with centre alignment t.

Inside that is your image.

You need to set the alignment to center inside attribute inspector of UIStackView

Check attribute inspector for stackview settings:

follow these steps.

1) drag Uiimageview.

2) click on UIimageview. Press Ctrl and drag downward or sidewise to parent view.

3) click on "centre vertically in view" and centre "horizontally in view"

4) then set height and width like below.

Thats it. your imageview will be at centre regardless of the device type. good luck.

leave a comment if you any question. Accept the answer if it helps you.

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