Search code examples
iosxcodebuttonalignmentinterface-builder

How dynamically align button in xCode


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?

enter image description here


Solution

  • 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.