Fon*_*nix 12
在iOS上实现Androids .GONE功能的唯一方法是使用UIStackView
通过苹果文档
动态更改堆栈视图的内容无论何时添加,删除或插入已排列的视图数组中的视图,或者每当其中一个已排列的子视图的隐藏属性发生更改时,堆栈视图都会自动更新其布局.
SWIFT 3:
Run Code Online (Sandbox Code Playgroud)// 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 = trueSWIFT 4:
Run Code Online (Sandbox Code Playgroud)let firstView = stackView.arrangedSubviews[0] firstView.isHidden = true