amb*_*ent 17 animation uiview ios swift
我正在努力弄清楚如何允许用户与视图进行交互,因为它正在被动画化.
情况就是这样:我有一个UIView cardView,它包含card子视图.该cards为可拖动的瓷砖,类似打火卡如何拖动/滑动式.
我试图animateWithDuration通过动画来淡出卡片cardView.alpha = 0.从逻辑上讲,这也将淡出所有子视图(card对象).在这种特定情况下,我只针对一个card子视图.但是,在动画期间,我无法拖动/与之交互card.
这是我正在使用的代码:
UIView.animateWithDuration(
duration,
delay: 0,
options: UIViewAnimationOptions.AllowUserInteraction,
animations: {self.cardView.alpha = 0}
) {
_ in
println("Card faded out")
card.removeFromSuperview()
}
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?任何帮助将不胜感激.谢谢!!
Eri*_*icS 11
我通过将alpha设置为0.1而不是0.0来解决此问题.我不确定这是否适用于您的情况,但它表明事件处理代码认为视图不可见,并且即使设置了UIViewAnimationOptionAllowUserInteraction标志也禁用了交互.奇怪的是,将alpha设置为0.01无效,因此您必须保持高于可见度的阈值.
小智 5
斯威夫特 5
UIView.animateKeyframes(withDuration: 0.5, delay: 0, options: [.repeat, .autoreverse, .allowUserInteraction], animations: {
self.customButton.backgroundColor = .none
}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5776 次 |
| 最近记录: |