Bring life to CALayers with SpriteKit-like animation builders

Related tags

Animation Animo
Overview

Animo

Version Platform License Carthage compatible

Bring life to CALayers with SpriteKit-like animation builders.

preview

Why use Animo?

Because declaring CAAnimations (especially with CAAnimationGroups) is very verbose and tedious.

Animo turns this:

let positionAnimation = CABasicAnimation(keyPath: "position")
positionAnimation.fromValue = NSValue(CGPoint: fromPoint)
positionAnimation.toValue = NSValue(CGPoint: toPoint)

let colorAnimation = CABasicAnimation(keyPath: "backgroundColor")
colorAnimation.fromValue = fromColor.CGColor
colorAnimation.toValue = toColor.CGColor

let animationGroup = CAAnimationGroup()
animationGroup.animations = [positionAnimation, colorAnimation]
animationGroup.fillMode = kCAFillModeForwards
animationGroup.removedOnCompletion = false
animationGroup.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)

someView.layer.addAnimation(animationGroup, forKey: "animationGroup")

to this:

someView.layer.runAnimation(
    Animo.group(
        Animo.move(from: fromPoint, to: toPoint, duration: 1),
        Animo.keyPath("backgroundColor", from: fromColor, to: toColor, duration: 1),
        timingMode: .EaseInOut,
        options: Options(fillMode: .Forwards)
    )
)

Feature List

  • All timing modes from http://easings.net/ are implemented.
  • Choose how to mix your animations with grouping utilities:
    • group(...)
    • sequence(...)
    • autoreverse(...)
    • wait(...)
    • replay(...) and replayForever(...)
  • No need to box native types and struct types in NSValues! Animo will do that for you for:
    • Int8
    • Int16
    • Int32
    • Int64
    • UInt8
    • UInt16
    • UInt32
    • UInt64
    • Int
    • UInt
    • CGFloat
    • Double
    • Float
    • CGPoint
    • CGSize
    • CGRect
    • CGAffineTransform
    • CGVector
    • CATransform3D
    • UIEdgeInsets
    • UIOffset
    • NSRange
  • No need to bother between CGColor and UIColor! Animo automatically converts the following types for you so you can just use UIKit objects all the time:
    • UIColorCGColor
    • UIImageUIImage
    • UIBezierPathCGPath
  • Don't bother type-casting M_PI anymore and just use Degrees-to-Radians (and vice-versa) extensions for CGFloat, Double, and Float!

Here's a slightly complex animation that showcases what else you can do with Animo:

someView.layer.runAnimation(
    Animo.sequence( // Runs a list of animations in sequence
        Animo.wait(1), // Waits for a certain interval before running the next animation
        Animo.replayForever( // Replays the animation endlessly
            Animo.sequence(
                Animo.move( // Moves the layer's position
                    by: CGPoint(x: 100, y: 200), // "by", "from", and "to" arguments are supported
                    duration: 2,
                    timingMode: .Spring(damping: 1) // simplistic spring function that doesn't rely on physics
                ),
                Animo.rotateDegrees( // Rotates the layer (degrees and radians variants are supported)
                    by: -180,
                    duration: 1,
                    timingMode: .EaseInOutBack
                ),
                Animo.autoreverse( // Auto-reverses the animation
                    Animo.keyPath(
                        "cornerRadius", // Any custom KVC key is supported as well!
                        to: 10,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    )
                ),
                Animo.group( // Runs multiple animations together
                    Animo.scaleX(
                        by: 2,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    ),
                    Animo.scaleY(
                        by: 0.5,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    )
                ),
                Animo.wait(1),
                Animo.move(
                    by: CGPoint(x: -100, y: -200),
                    duration: 2,
                    timingMode: .EaseInOutBack
                ),
                Animo.rotateDegrees(
                    by: 180,
                    duration: 1,
                    timingMode: .EaseInOutBack
                ),
                Animo.group(
                    Animo.scaleX(
                        to: 1,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    ),
                    Animo.scaleY(
                        to: 1,
                        duration: 1,
                        timingMode: .EaseInOutBack
                    )
                )
            )
        )
    )
)

Install with CocoaPods

Add

pod 'Animo'

to your Podfile and run pod install

Install with Carthage

Add

github "eure/Animo" >= 1.2.0

to your Cartfile and run carthage update

Install as Git Submodule

Run

git submodule add https://github.com/eure/Animo.git <destination directory>

To install as a framework:

Drag and drop Animo.xcodeproj to your project.

To include directly in your app module:

Add all .swift files to your project.

License

Animo is released under an MIT license. See the LICENSE file for more information.

You might also like...
Tinder/Bumble like user image with user details scroll animation
Tinder/Bumble like user image with user details scroll animation

TinderUserProfile Tinder/Bumble like user image with user details scroll animation Add ProfileView.m,ProfileView.h class to your project. Set the clas

ChainPageCollectionView  A custom View with two level chained collection views and fancy transition animation
ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation

ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation. Demo Requirements iOS 9.0+ Xcode 8 Insta

A DSL to make animation easy on iOS with Swift.
A DSL to make animation easy on iOS with Swift.

This project is highly inspired by JHChainableAnimations, If you project is developed with Objective-C, use JHChainableAnimations instead. With DKChai

Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers
Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers

Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers. It's magic. Features Animate a

Elegant SVG animation kit for swift
Elegant SVG animation kit for swift

Elephant This is SVG animation presentation kit for iOS. Example You can run example app. Please open Example-iOS/Elephant-iOS.xcworkspace! Usage You

Gemini is rich scroll based animation framework for iOS, written in Swift.
Gemini is rich scroll based animation framework for iOS, written in Swift.

Overview What is the Gemini? Gemini is rich scroll based animation framework for iOS, written in Swift. You can easily use GeminiCollectionView, which

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.
Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

A Fast Animation Engine with an Intuitive API
A Fast Animation Engine with an Intuitive API

Kinieta An Animation Engine for iOS with an Intuitive API and Readable Code! (Written in Swift 4.0.) Why another? I decided to build an Animation Engi

Pulse animation for iOS written with Swift.
Pulse animation for iOS written with Swift.

Pulsator Pulse animation for iOS written with Swift. Great For: Pulses of Bluetooth, BLE, beacons (iBeacon), etc. Map Annotations Installation CocoaPo

Comments
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull requests corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    opened by ReadmeCritic 2
  • Can't interact with UIView after animation

    Can't interact with UIView after animation

    Hi there.

    Basically I am having issues interacting with segments I have inside my UIView after an animation has been done. In other words, I can't seem to click any button, or scroll any text view. How come?

    I have tried to play with completion blocks, and do myView.isUserInteractionEnabled = true etc. Any ideas on how I can fix this? If I stop the animation, the UIView moves back to the position I don't want it to be in. In other words, I want it to stay.

    opened by askaale 1
  • rotate using an enum type

    rotate using an enum type

    Great lib ! One improvement would be to use an enum type inside a common rotate method like such:

    Animo.rotate(.Degree(-180))
    Animo.rotate(.Radian(-M_PI))
    

    Definitely a nice to have, what do you think ?

    enhancement 
    opened by apouche 1
Owner
エウレカ
This is eureka, Inc. organization.
エウレカ
An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.

Orbital-SwiftUI-Animation An experiment for using SwiftUI's custom timing curve to create an orbital-like animation. How it looks: How it works: Apply

Mostafa Abdellateef 7 Jan 2, 2023
ViewAnimator brings your UI to life with just one line

ViewAnimator is a library for building complex iOS UIView animations in an easy way. It provides one line animations for any view included the ones wh

Marcos Griselli 6.9k Jan 2, 2023
Simple Interface Core Animation. Run type-safe animation sequencially or parallelly

Simple Interface Core Animation Sica can execute various animations sequentially or parallelly. Features Animation with duration and delay parallel /

CATS Open Source Softwares 1k Nov 10, 2022
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

⚠️ This repository is under construction. SwiftUI Text Animation Library Make yo

null 28 Jan 8, 2023
Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks

SwiftUI Animation Observer Track SwiftUI animation progress and completion via c

Gordan Glavaš 9 Nov 5, 2022
Better Easing for SpriteKit in Swift

This easing library began life as a port of buddingmonkey's Objective C SpriteKit Easing library to Swift. This library extends upon the basic easing

Craig Grummitt 110 Dec 17, 2022
Compose SpriteKit animations quickly in a declarative SwiftUI-style

ActionBuilder Caveat developer: As this package is pre-release, the API may change significantly without notice. It has not been tested, so use it at

Kuba Szulaczkowski 6 Dec 30, 2022
🎨 Gradient animation effect like Instagram

Pastel ?? Gradient animation effect like Instagram Example override func viewDidLoad() { super.viewDidLoad() let pastelView = PastelView(fram

Cruz 3.4k Jan 1, 2023
FloatingBubbles is a customizable views that float like zero gravity animation.

Floating Bubbles FloatingBubbles is a customizable views that float like zero gravity animation. $ pod try FloatingBubbles Features Create Multiple V

Chandan Sharda 18 Oct 11, 2022