YapAnimator
1.0.0

Yapanimator是您基于物理的快速友好的动画系统。 Yapanimator的构建是易于使用的,使您和您的设计师非常非常高兴。所有动画都是可中断的,包括完成块,并允许您向其施加力(例如,在过渡中添加速度)。我们包括了一些常见动画类型( CG类型)的Animatable协议符合性,但是添加与任何其他类型的一致性确实很容易。您可以用一系列Double s来制作任何可以代表和构成的东西 - 查看属性,音乐卷,bezier路径,颜色,平滑笔触之间的变形,列表继续……使用您的想象力!
因为它非常易于使用并制作精美的动画,所以这就是原因。那里还有其他基于物理的动画系统(例如Uikit的春季动画,Facebook的流行音乐),但是他们仍然需要编写太多的代码,簿记和手工握持的方式。 Yapanimator代表了我们在自己的应用程序中使用多年的代码的蒸馏n-thth迭代。我们发现它在我们的日常工作中无价之宝,并认为您也会。
Yapanimator带有一个方便的扩展名,固定在CALayer和UIView / NSView上,分别在animatedLayer和animated属性下提供单线动画。

func handle ( gesture : UIPanGestureRecognizer ) {
if gesture . state == . began {
squircle . animated . cornerRadius . animate ( to : squircle . bounds . width / 2.0 )
squircle . animated . rotationZ . animate ( to : . pi )
else if gesture . state == . changed {
squircle . animated . position . instant ( to : gesture . location ( in : nil ) )
} else if gesture . state == . ended {
squircle . animated . position . animate ( to : self . view . center )
squircle . animated . cornerRadius . animate ( to : 0 )
squircle . animated . rotationZ . animate ( to : 0 )
}
} 创建自定义动画师很简单:
initialValue这将设置动画师的初始值,并告知它将为哪种类型进行动画。willBegin在运动开始之前打电话。返回您要动画的属性的实际值。这允许动画仪与该值同步,以防该值在动画师的范围之外更改。 (选修的)eachFrame框架称为动画的每个帧 - 通常是您将动画仪的current.value应用到您正在动画的属性的地方。您也可以使用它来检查值以触发其他操作 /动画。 frameAnimator = YapAnimator ( initialValue : square . frame , willBegin : { [ unowned self ] in
return self . square . frame
} , eachFrame : { [ unowned self ] ( animator ) in
self . square . frame = animator . current . value
} ) 
frameAnimator . bounciness = 1.5
frameAnimator . animate ( to : square . frame . insetBy ( dx : - 50 , dy : - 50 ) , completion : { animator , wasInterrupted in
if !wasInterrupted {
// animate back to the original value
animator . animate ( to : animator . current . value . insetBy ( dx : 50 , dy : 50 ) )
}
} ) 在问题中随时提出您的问题。我们将在那里做出回应,如果答案似乎将使他人受益,请修改此阅读/启动Wiki。
Yapanimator由YAP Studios拥有和维护。