使UIViewPropertyAnimator永远不会完成 [英] Make a UIViewPropertyAnimator never complete
问题描述
我有一个 UIViewPropertyAnimator
管理模糊等等,我想要仅将其用于 fractionComplete
属性。问题是,如果我将 fractionComplete
设置为 1.0
,它将完成并删除所有动画,我想要保持。
I have a UIViewPropertyAnimator
managing a blur, among other things, and I'd like to use it just for its fractionComplete
property. The problem is that if I set fractionComplete
to 1.0
, it completes and removes all animations, which I'd like to keep.
基本上,我不希望动画师完成,因为它会清除动画块。
Basically, I don't want the animator to complete because that clears its animation blocks.
- 完成后重新添加动画
- Clamp
fractionComplete
类似0.001 ... 0.999
- Re-add animations upon completion
- Clamp
fractionComplete
to something like0.001...0.999
推荐答案
现在可以设置iOS11
With iOS11 is now possible to set
var pausesOnCompletion: Bool { get set }
当此属性的值为true时,动画师在动画时保持
活动状态完成,并且它不执行其
完成处理程序。保持动画制作者处于活动状态允许
即使在完成后也可以反转动画。当此属性的
值为false时,动画师会自动将
转换为动画结束时的非活动状态,
从而结束动画。此属性
的默认值为false。
When the value of this property is true, the animator remains in the active state when the animation finishes, and it does not execute its completion handler. Keeping the animator in the active state allows you to reverse the animation even after it has finished. When the value of this property is false, the animator automatically transitions to the inactive state when the animation finishes, thereby concluding the animation. The default value of this property is false.
source: https://developer.apple.com/documentation/uikit/uiviewpropertyanimator/2909004-pausesoncompletion
这篇关于使UIViewPropertyAnimator永远不会完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!