为CAAnimation对象添加开始、动画和完成闭包的Swift扩展。
即,CAAnimation + Closure 或 CAAnimation + Block。
只需将CAAnimation+Closure.swift
文件添加到您的项目中即可。
let animation = CABasicAnimation(keyPath: "strokeEnd")
animation.duration = 2.0
animation.fromValue = 0.0
animation.toValue = 1.0
animation.start = {
println("Woo, the animation starts!")
// ...
}
strokeEndAnimation.animating = { progress in
println("progress: \(progress)")
// ...
}
animation.completion = { finished in
println("Awesome, the animation just finished! :)")
// ...
}
layer.addAnimation(animation, forKey: "strokeEndAnimation")
layer.addAnimationWithCompletion(animation, forKey: "strokeEndAnimation", withCompletion: {finished in
println("Animation is finished")
})
The MIT License (MIT)
版权所有 © 2015 张宏昊
在此特此授予任何获取此软件及其关联文档(以下简称“软件”)副本的个人,在不受限制的情况下处理该软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,以及允许向获得该软件的人提供上述权利的权利,前提是必须遵守以下条件
上述版权声明和许可声明应包含在软件的所有副本或主要部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于 merchantability、适销性、针对特定目的的适用性和 non-infringement 的保证。在任何情况下,作者或版权持有人不对任何索赔、损害或其他责任负责,无论是否因合同、侵权或其他行为而引起,无论是否与软件或软件的使用或其他操作有关。