I have such layout with two buttons. When I click on Button 1
it has to disappear and Button 2
has to be moved to center of layout. How can I perform this properly?
Asked
Active
Viewed 557 times
0

Alexander
- 161
- 2
- 14
-
What is your deployment target? – Lysdexia May 23 '17 at 09:53
-
iOS10 I suppose – Alexander May 23 '17 at 09:56
-
Consider using of *autolayout* or *UIStackView* – Jakub Truhlář May 23 '17 at 10:26
2 Answers
2
You can do it with StackView.set StackView center horizotal and vertical alignment
and also set in StackView attributes inspector
set alignment center and distribution Equal centering. Set both button width fixed.

Donal
- 6,082
- 2
- 19
- 30
1
Use StackView. You don't have to think about any layout constraint.That is center aligned. When you hide something from stackView it will automatically get centered according to your need.

elk_cloner
- 2,049
- 1
- 12
- 13
-
Try this link.It's a nice tutorial. https://www.raywenderlich.com/114552/uistackview-tutorial-introducing-stack-views – elk_cloner May 23 '17 at 09:57