Search code examples
iosxcodeios-ui-automationios-autolayout

How to hide views in ios at runtime with auto layouts such that the ui stays consistent?


I am attaching the image of my ui here.

User Inteface:

enter image description here

I want to make the buttons with grievance details and mdm details captions hidden at runtime depending on the condition but I want the button with logout caption to shift upwards automatically. But its not happening. I am attaching the image of my result.

UI after removing the two buttons:

enter image description here

And here is the image of the constraints applied on the button with the caption logout.

Constraints applied on the logout button:

enter image description here


Solution

  • If your app's Deployment Target is above iOS 9 then you should use UIStackView. You can easily achieve with UIStackView.

    Check this