Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 876
Siddharth Shah Avatar asked May 20 '16 06:05

Siddharth Shah


1 Answers

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.

SWIFT 3:

// 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

SWIFT 4:

let firstView = stackView.arrangedSubviews[0]
firstView.isHidden = true
like image 119
Fonix Avatar answered Sep 28 '22 04:09

Fonix