有人知道隐藏标签并让屏幕的其他 View 使用留空的地方的简单方法吗?并在展示该 View 时做相反的事情。类似于 Android setVisibility = GONE 的图层。
据我所知,使用 setHidden=true 只会从屏幕上隐藏 View ,但不会重新排列它周围的任何东西。
谢谢
最佳答案
在 iOS 上实现 Android .GONE 功能的唯一方法是使用 UIStackView
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
关于android - 如何在 IOS 中像 android 一样设置可见性 GONE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37339793/