• Stars
    star
    282
  • Rank 146,549 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bring life to CALayers with SpriteKit-like animation builders

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:
    • UIColor โ†’ CGColor
    • UIImage โ†’ UIImage
    • UIBezierPath โ†’ CGPath
  • 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.

More Repositories

1

swift-style-guide

Coding conventions and best practices for Swift projects
284
star
2

AppVersionMonitor

Monitor iOS app version easily.
Swift
259
star
3

citrus

Fantastic animations and custom views for a good design
Java
238
star
4

RealmIncrementalStore

Realm-powered Core Data persistent store
Swift
230
star
5

Storybook-ios

UI Component previewer for UI development faster in iOS (Currently supports only UIKit)
Swift
190
star
6

ScrollEdgeControl

โ™ป๏ธ Replacement of UIRefreshControl, and more functions.
Swift
57
star
7

kamimai

๐Ÿงป ็ด™่ˆž - Kamimai is a migration manager written in Go
Go
46
star
8

traveling

Kotlin
24
star
9

AssetsPicker

๐ŸžThe UI library to pick PHAsset
Swift
14
star
10

RSS-Swift

Swift
11
star
11

FlatStore

[Experimental] FlatStore is a memory-only data storage library written at Eureka
Swift
10
star
12

appsflyer

AppsFlyer API client library for Go.
Go
8
star
13

bobo

Slack Bot Kit for Golang
Go
8
star
14

Tower

๐Ÿ—ผ Watching git branches, the new commits on each branch run scripts.
Swift
8
star
15

SpringFlowLayoutExample

Swift
7
star
16

slslog

CW Logs Insight ใง trace ใงไธ€้€ฃใฎๅ‡ฆ็†ใ‚’่ฟฝใ†ใ“ใจใฎใงใใ‚‹ Logger ใงใ™ใ€‚
Go
5
star
17

pairs-web-card-example

Web Front-end Team, Pairsใฎใ‚คใƒณใ‚ฟใƒผใƒณ้ธ่€ƒใฎๆŠ€่ก“่ชฒ้กŒใฎๅ›ž็ญ”ไพ‹
JavaScript
3
star
18

example-blog-golang

example codes for blog article
Go
2
star
19

cafe-bot

Slack bot for Archimedes Cafe
Go
1
star
20

PushTower

๐Ÿ—ผ Dispatch Remote Push Notification Packages [Core <- Server | DesktopApp]
Objective-C
1
star
21

bobo-googlehome

Google Home Commands and Tasks for eure/bobo (Slackbot)
Go
1
star