【发布时间】:2019-01-16 23:41:30
【问题描述】:
我没有经常使用UIViewPropertyAnimator(仍然是一个老式的积木人)并且我看到了一些我无法解释的行为并且文档并没有真正提供任何见解。
为什么动画师的完成块会被 finalPosition 或 .end 调用,即使动画师在启动后立即暂停?
let view = UIView()
let animator = UIViewPropertyAnimator(duration: 4, curve: .linear, animations: {
view.alpha = 0
})
animator.addCompletion { position in
print("done")
switch position {
case .start: print("start")
case .current: print("current")
case .end: print("end")
}
}
animator.startAnimation()
print("starting")
animator.pauseAnimation()
print("pausing")
输出:
starting
pausing
done
end
【问题讨论】:
-
Session 216 from WWDC 216 和 Session 230 from WWDC 2017 如果您开始与属性动画师一起玩,两个小时的时间非常值得。非常好的介绍。
-
感谢您提供的链接——这两个我过去都看过,会再试一次。
标签: ios swift uikit uiviewpropertyanimator