gpt4 book ai didi

ios - UIView.animate 没有为我的 UIVisualEffectView 设置动画

转载 作者:行者123 更新时间:2023-11-28 08:12:23 26 4
gpt4 key购买 nike

我在 IB 中创建了一个 UIVisualEffectView 和一个属性

@IBOutlet weak var visualEffectStack: UIVisualEffectView!

我可以使用

显示和隐藏视觉效果 View
visualEffectStack.isHidden = false
visualEffectStack.isHidden = true

或使用 alpha。

我想为 View 的外观设置动画,但它没有设置动画。

visualEffectStack.alpha = 0
visualEffectStack.isHidden = false

UIView.animate(withDuration: 0.5, delay: 0.5, options: [.curveEaseIn, .beginFromCurrentState], animations: {
self.visualEffectStack.alpha = 1
})

是我的代码有问题还是视觉效果 View 有问题?

swift 3.1 和 iOS 10

最佳答案

在做了更多研究后,我发现 UIVisualEffectView 应该始终保持 alpha = 1。因此动画 alphaisHidden 永远不应该做完了。

来自 Apple's documentation :

Setting the Correct Alpha Value

When using the UIVisualEffectView class, avoid alpha values that are less than 1. Creating views that are partially transparent causes the system to combine the view and all the associated subviews during an offscreen render pass. UIVisualEffectView objects need to be combined as part of the content they are layered on top of in order to look correct. Setting the alpha to less than 1 on the visual effect view or any of its superviews causes many effects to look incorrect or not show up at all.

关于ios - UIView.animate 没有为我的 UIVisualEffectView 设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43379675/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com