TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | Apache 2 |
ReleasedLast Release | Nov 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Jeff Verkoeyen.
The Core Animation Material Motion family provides a bridge between Core Animation and the Material Motion runtime.
Tween
uses Core Animation’s CABasicAnimation to animate a CALayer property along an easing curve.
Use a Tween like you would use a CABasicAnimation instance: provide a key path, duration, and one or both of the from/to value.
let tweenBackgroundColor = Tween("backgroundColor", duration: animDuration)
tweenBackgroundColor.from = UIColor.orange.cgColor
tweenBackgroundColor.to = UIColor.lightGray.cgColor
scheduler.addPlan(tweenBackgroundColor, to: myView)
Tween’s properties map to the following Core Animation properties:
Tween | Core Animation |
---|---|
delay | delay |
duration | duration |
from | fromValue |
keyPath | keyPath |
to | toValue |
timingFunction | timingFunction |
No other Core Animation properties are presently supported. View our filed feature requests to track progress on supporting additional functionality.
Import the framework:
@import MaterialMotionCoreAnimationFamily;
You will now have access to all of the APIs.
Check out a local copy of the repo to access the Catalog application by running the following commands:
git clone https://github.com/material-motion/material-motion-family-coreanimation-swift.git
cd material-motion-family-coreanimation-swift
pod install
open MaterialMotionCoreAnimationFamily.xcworkspace
Code snippets:
In Objective-C:
MDMTween *tween = [[MDMTween alloc] initWithKeyPath:@"<#key path#>" duration:<#duration#>];
tween.from = <#from value#>;
tween.to = <#to value#>;
[scheduler addPlan:tween to:<#Object#>];
In Swift:
let tween = Tween(<#key path#>, duration: <#duration#>)
tween.from = <#from value#>
tween.to = <#to value#>
scheduler.addPlan(tween, to: <#Object#>)
We provide two helper APIs for committing the to/from value of a Tween plan to a given CALayer instance. This is most often used to commit the to
value of the Tween to the layer so that the property does not appear to “snap back” upon completion of the animation.
Code snippets:
In Objective-C:
[tween commitToValueTo:<#CALayer#>]
In Swift:
tween.commitToValue(to: <#CALayer#>)
We welcome contributions!
Check out our upcoming milestones.
Learn more about our team, our community, and our contributor essentials.
Licensed under the Apache 2.0 license. See LICENSE for details.