ChainedAnimation 4.0.0

ChainedAnimation 4.0.0

测试已测试
语言语言 SwiftSwift
许可 MIT
发布上次发布2017 年 10 月
SwiftSwift 版本3.0
SPM支持 SPM

Silvan Dähn 维护。



ChainedAnimation

使用方法

要运行示例项目,请克隆仓库,并运行 Example 应用目标。

使用不同延迟顺序多个动画。链式动画将在最后一个动画执行后开始延迟。

您可以在 UIView 类上使用 -beginAnimationChain 函数创建链式动画。

UIView.beginAnimationChain(0.5) {
  view.frame.origin.y = 170
}.animate()

您可以为 UIViewAnimationOptions 提供可选延迟。

UIView.beginAnimationChain(0.5, delay: 0.2, options: .CurveEaseInOut) {
  view.frame.origin.y = 170
}.animate()

要添加偏移动画,请使用 -thenAfterStart: 函数并附加一个将在最后一个动画开始延迟后执行的动画闭包。将完成闭包添加到动画链中,它将在链中的上一个动画完成后执行。

UIView.beginAnimationChain(0.5, options: .CurveEaseInOut) {
  view.frame.origin.y = 170
}.thenAfterStart(0.1) {
  // This animation will be started 0.1 seconds
  // after the previous one started
  otherView.tranform = awesomeTransform
}.thenAfterStart(0.15) {
  // More shiny animations
}.completion { bool in
  // Do something nice on completion. Or don't.
}.animate()

也可以在先前的链完成后添加新链。要添加新链,请调用 -chainAfterCompletion: 并开始添加带有偏移的动画块。

UIView.beginAnimationChain(0.33, options: .CurveEaseInOut) {
  view.frame.origin.y = 170
}.thenAfterStart(0.15) {
  // Start animations with a delayed start
}.completion { bool in
  // Do something nice on the completion of the first chain.
}.chainAfterCompletion(1.2, options: .CurveEaseIn) {
    // This animation will be started after the last
    // animation in the first chain completed
}.thenAfterStart(0.1) {
    // This animation will be started 0.1 seconds after
    // the first animation in the second chain started
}.completion { _ in
    // Do something nice on the completion of the second chain.
}.animate()

作者

Silvan Dähn, @silvandaehn

许可

Chain 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。