Easy animation library on iOS with Swift2

Related tags

Animation Cheetah
Overview

Cheetah

Carthage compatible Pod Version Swift Version License MIT Plaforms

Cheetah is an animation utility on iOS with Swift. Cheetah can animate any properties since Cheetah uses simple CADisplayLink run loop to change animated properties.

Requirements

  • iOS 8.0~
  • tvOS 9.0~
  • Swift 3.0

Features

  • Animation with duration and delay
  • Changing with absolute/relative properties
  • Parallel/Serial executions
  • Easings
  • Springs

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa.

To install Cheetah, simply add the following line to your Cartfile:

github "suguru/Cheetah"

Code Example

// Create view
let box = UIView(frame:CGRectMake(100,100,50,50))
box.backgroundColor = UIColor.blueColor()
view.addSubview(box)

// Move to 100px right
box.cheetah.move(100, 0).run()

Simple move

Properties

Cheetah has several methods to animate properties easily. You can also animate your own properties with extending CheetahProperty.

  • move
  • position (absolute of move)
  • scale
  • rotate
  • rotation (absolute of rotate)
  • size
  • frame
  • alpha
  • backgroundColor
  • textColor
  • borderColor
  • borderWidth
  • borderRadius
  • custom properties

Parallel execution

Cheetah groups animation properties and execute them at once.

view.cheetah
  .move(100, 0)
  .rotate(M_PI * 2)
  .scale(1.5)
  .run()

Parallel

Serial execution

wait will wait until all animations placed before it completed. It can also receive seconds to wait to start next animation.

view.cheetah
  .move(100, 0).rotate(M_PI)
  .wait()
  .move(-100, 0).rotate(-M_PI)
  .wait(1.0) // <- wait 1 sec to start next animation
  .move(0, -20).duration(0.4)
  .wait()
  .move(0, 20).duration(0.4)
  .run()

Serial

Duration and delay

Cheetah has duration and delay to each animation properties.

view.cheetah
  .move(100, 0).duration(1.0).delay(1.0)
  .rotate(M_PI).duration(2.0)
  .wait(1)
  .move(-100, 0).duration(0.4)
  .run()

Delay

Duration will be copied from the property placed before.

view.cheetah
  .duration(0.5)
  .move(100, 0) // <- will have 0.5 sec duration
  .rotate(M_PI) // <- will have 0.5 sec duration
  .run()

Repeating

To repeat animations, use repeatCount(count: Int)

view.cheetah.rotate(M_PI_2).run().repeat(3)

To repeat forever, use forever

view.cheetah.rotate(M_PI_2).run().forever

Repeat

Easings

Cheetah supports various easing functions. You can also add custom easings with quad bezier points.

Easings

Exmaple

view.cheetah.move(150, 150).easeInQuad.run()

Supported eassing equations

  • Linear
  • Sine
  • Quad
  • Quart
  • Quint
  • Circ
  • Cubic
  • Expo
  • Back
  • Bounce
  • Elastic

Springs

Cheetah supports spring dynamics with tension and friction parameters.

Springs

Example

view.cheetah
  .move(200, 0)
  .spring()
  .run()

view.cheetah
  .move(200, 0)
  .spring(tension: 100, friction: 4)
  .run()

Animate custom properties

You can extend CheetahProperty to animate custom properties. You can refer CheetahViewProperties.swift and CheetahLayerProperties.swift.

:)

Comments
  • Can not import the library

    Can not import the library

    Hi guys, I am using Carthage to import your library but I received this message: *** Checking out Cheetah at "0.2.6" *** xcodebuild output can be found in /var/folders/d7/tmh15dlx1fj4vqz0sqwrk6knmz_k04/T/carthage-xcodebuild.TasAd5.log xcodebuild timed out while trying to read CheetahExample.xcodeproj 😭 And nothing was imported in Build/tvOS folder Any idea ?

    opened by PierreRAFFA 4
  • Spring and Completion closure

    Spring and Completion closure

    It looks like there is a race condition of some sort going on with spring() and calling completion(). Everything works fine with any of the other animation methods, however spring does not call completion when running. However, if I debug the CheetahProperties procede function by placing a breakpoint on the check to see if spring has ended, completion will be called - seems like something is getting ahead of itself... I'll try to debug further soon!

    opened by retznutz 1
  • Keep transform matrix after finishing CheetahProperty

    Keep transform matrix after finishing CheetahProperty

    Transform properties are calculated every frame. Currently, CheetahProperty disposed when finished its duration. It causes resetting transformed variables during animating multiple properties which has different durations. Cheetah should keep transform matrix after finished when matrix does not equal to identity matrix.

    opened by suguru 0
  • Cannot start new animation on completion

    Cannot start new animation on completion

    I want to be able to do a 3 - 2 - 1 countdown animation on a view which has a label inside. However it does not work. I have been trying to figure out why but believe its to do with something not being reset after first animation sequence. Here is my code.

        countinView.cheetah
            .scale(2).duration(0.3)
            .wait(0.4)
            .scale(0).duration(0.3)
            .rotate(Double.pi*2).duration(0.3)
            .alpha(0).duration(0.3)
            .run()
            .completion {
                self.countInValue = self.countInValue - 1
                if self.countInValue > 0 {
                    self.showCountInLabel()
                } else {
                    self.timerBarStartTimer()
                }
        }
    
    opened by PJDavis1970 0
  • How to group animations?

    How to group animations?

    Hello Guys,

    I would like to setup animations for different views, and trigger them combined at different times.

    I.e:

    let anim1 = view1.cheetah.scale(0)
    let anim2 = view2.cheetah.alpha(0)
    let anim3 = view3.cheetah.move(10,10)
    
    // then do
    [anim1, anim2].run()
    // or
    [anim3, anim1].run()
    

    Is there a way to accomplish that? Ideally I would also like to have a single completion blocked called when all of them are done (which may have different durations).

    Thanks, H.

    opened by hernangonzalez 0
  • Swift 3 and SwiftPM support

    Swift 3 and SwiftPM support

    opened by TofPlay 0
Owner
Suguru Namura
Suguru Namura
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
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
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
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
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
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

Draven 1.9k Dec 9, 2022
Wave is a spring-based animation engine for iOS that makes it easy to create fluid, interruptible animations that feel great.

Wave is a spring-based animation engine for iOS and iPadOS. It makes it easy to create fluid, interactive, and interruptible animations that feel great.

Janum Trivedi 1.2k Jan 8, 2023
Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.

Letters Animation Cool Letters Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 31 Oct 4, 2022
Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.

Numbers Animation Cool Numbers Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 31 Oct 4, 2022
Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.

Reading Animation Cool Reading Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 42 Oct 4, 2022
Swift animation made easy

Fluent Swift Animations made Easy Installation Add the following to your Podfile and run pod install pod 'Fluent', '~> 0.1' or add the following

Matthew Cheok 300 Jul 15, 2022
CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation

CCMRadarView CCMRadarView is a simple to use view that uses the new IBDesignable and IBInspectable features of XCode6 to easily configure the icon in

Carlos Compean 183 Sep 17, 2022
MGFlipView allows to create flipping view in easy way without worrying about flipping animation and flipping logic.

MGFlipView About If you are looking for an easy way of implement 3D flipping view, you are in the right place. MGFlipView allows to create flipping vi

Maciej Gomółka 47 Sep 28, 2022
BWMCoverView is a very easy to use advertising the carousel view, supports circular scrolling functions such as switching, asynchronous loading of images, animation, custom is very high.

BWMCoverView BWMCoverView is a very easy to use advertising the carousel view, supports circular scrolling functions such as switching, asynchronous l

Bi Weiming 31 Mar 10, 2021
Swift easy app launcher animation.

SwiftLauncher Swift easy app launcher animation. Usage. // Twitter. let logoLayer = CALayer() logoLayer.bounds = CGRect(x: 0, y: 0, width:

iOS.Jett 1 May 25, 2022
A radical & elegant animation library for iOS.

Installation • Usage • Debugging • Animatable Properties • License Dance is a powerful and straightforward animation framework built upon the new UIVi

Saoud Rizwan 648 Dec 14, 2022
An extensible iOS and OS X animation library, useful for physics-based interactions.

Pop is an extensible animation engine for iOS, tvOS, and OS X. In addition to basic static animations, it supports spring and decay dynamic animations

Meta Archive 19.8k Dec 28, 2022
Swift animation library for iOS, tvOS and macOS.

anim is an animation library written in Swift with a simple, declarative API in mind. // moves box to 100,100 with default settings anim { self.bo

Onur Ersel 555 Dec 12, 2022