siddharth shah siddharth shah - 1 year ago 301
iOS Question

how to set visibility GONE like android in IOS?

Anybody know a simple way to hide a label and let the other views of the screen use the place left blank ? And make the opposite when showing back that view. Something like Android setVisibility = GONE for layers.

As far as I know, using setHidden=true only hide the view from the screen but does not rearrange anything around it.

Thank you
Hope i got answer

Answer Source

The only way to achieve Androids .GONE functionality on iOS is to use a UIStackView

via Apples documentation

Dynamically Changing the Stack View’s Content The stack view automatically updates its layout whenever views are added, removed or inserted into the arrangedSubviews array, or whenever one of the arranged subviews’s hidden property changes.


// Appears to remove the first arranged view from the stack.
// The view is still inside the stack, it's just no longer visible, and no longer contributes to the layout.
let firstView = stackView.arrangedSubviews[0]
firstView.hidden = true
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download