MaterialMotionCoreAnimationFamily 1.1.0

MaterialMotionCoreAnimationFamily 1.1.0

TestsTested
LangLanguage SwiftSwift
License Apache 2
ReleasedLast Release Nov 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Jeff Verkoeyen.


Downloads

Total153
Week0
Month0

Installs

Apps2
Test Targets1
powered by Segment

GitHub

Stars5
Watchers7
Forks2
Issues6
Contributors2
Pull Requests0

Code

Files3
LOCLines of Code 68


  • By
  • The Material Motion Authors

Core Animation Material Motion Family

The Core Animation Material Motion family provides a bridge between Core Animation and the Material Motion runtime.

Supported languages

  • Swift 3
  • Objective-C

Features

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.

Installation

Usage

Import the framework:

@import MaterialMotionCoreAnimationFamily;

You will now have access to all of the APIs.

Example apps/unit tests

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

Guides

  1. How to animate a property with a Tween plan
  2. How to commit Tween values to a layer

How to animate a property with a Tween plan

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#>)

How to commit Tween values to a layer

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#>)

Contributing

We welcome contributions!

Check out our upcoming milestones.

Learn more about our team, our community, and our contributor essentials.

License

Licensed under the Apache 2.0 license. See LICENSE for details.