Type-safe CAAnimation wrapper. It makes preventing to set wrong type values.
Switch branches/tags
Clone or download
Latest commit 4bbc96a Sep 26, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example support Swift4.2 Sep 26, 2018
Images update README May 14, 2018
TheAnimation.xcodeproj support Swift4.2 Sep 26, 2018
TheAnimation support Swift4.2 Sep 26, 2018
TheAnimationTests clean files Jul 2, 2018
.gitignore Initial commit May 11, 2018
.swift-version add .swift-version May 13, 2018
.travis.yml Initial commit May 11, 2018
LICENSE Initial commit May 11, 2018
README.md update README Sep 26, 2018
TheAnimation.podspec updat podspec Sep 26, 2018

README.md

TheAnimation

Platform Language Carthage Version License CI Status

TheAnimation is Type-safe CAAnimation wrapper.

Introduction

For example, if you want to animate backgroundColor with CABasicAnimation, you need to consider type because fromValue property and so on are Any?.

If you use BasicAnimation of TheAnimation, you can animate backgroundColor without considering type! (AnimationKeyPaths.backgroundColor is AnimationKeyPath<CGColor> type.)

Usage

The way of making an animation is almost similar CAAnimation. But you need to use animation.animate(in:) method instead of using layer.add(_:forKey:).

let view = UIView()

let animation = BasicAnimation(keyPath: .opacity)
animation.fromValue = 0
animation.toValue   = 1
animation.duration  = 1
animation.animate(in: view)

animation.animate(in:) returns AnimaitonCanceller. You can cancel an animation with it.

let canceller = animation.animate(in: view)
canceller.cancelAnimation()

Example

To run the example project, clone the repo, and open Example directory.

Correspondence Table

CAAnimation TheAnimation
CAPropertyAnimation PropertyAnimation
CABasicAnimation BasicAnimation
CAKeyframeAnimation KeyframeAnimation
CASpringAnimation SpringAnimation
CATransition TransitionAnimation
CAAnimationGroup AnimationGroup

Add new AnimationKeyPath

You can add AnimationKeyPath like this.

extension AnimationKeyPaths {
    static let newKeyPath = AnimationKeyPath<CGFloat>(keyPath: "abcd")
}

Requirements

  • Xcode 9.3
  • iOS 9 or greater
  • tvOS 9 or greater
  • macOS 10.11 or greater
  • Swift 4.2 (since 0.3.0)

Installation

Carthage

If you’re using Carthage, simply add TheAnimation to your Cartfile:

github "marty-suzuki/TheAnimation"

CocoaPods

TheAnimation is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'TheAnimation'

Author

marty-suzuki, s1180183@gmail.com

License

TheAnimation is available under the MIT license. See the LICENSE file for more info.