android - 如何在 IOS 中像 android 一样设置可见性 GONE?

标签 android ios iphone uilabel show-hide

有人知道隐藏标签并让屏幕的其他 View 使用留空的地方的简单方法吗?并在展示该 View 时做相反的事情。类似于 Android setVisibility = GONE 的图层。

据我所知,使用 setHidden=true 只会从屏幕上隐藏 View ,但不会重新排列它周围的任何东西。

谢谢

最佳答案

在 iOS 上实现 Android .GON​​E 功能的唯一方法是使用 UIStackView

通过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

关于android - 如何在 IOS 中像 android 一样设置可见性 GONE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37339793/

相关文章:

java - 尝试调用虚拟方法(EditText)

ios - 为什么 AVAudioPlayer 无法初始化? OSStatus 错误 1685348671?

ios - iOS 中的 AWS v2 SNS - createPlatformEndpoint :request

iphone - 我将一些数据发送到 Web 服务,它返回一些 JSON 作为 NSData。如何转换为Dict?(iOS 4.3)

iphone - SenTestingKit(与 XCode 集成)与 XCode 4 上的 GHUnit 进行单元测试?

android-activity - Admob Interstitial 加载但显示空白屏幕

java - 没有可用的默认构造函数

iPhone 应用程序崩溃并出现错误 [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary :]

Android 层列表 : bitmap issue with app:srcCompat

ios - 模态呈现时白色闪烁动画