Swift animation library for iOS, tvOS and macOS.

Overview

anim: Swift animation library for iOS, tvOS and macOS.


CocoaPods Carthage compatible Build Status codecov.io codebeat badge

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.box.frame.origin = CGPoint(x:100, y:100)
}
// after that, waits 100 ms
.wait(0.1)
// moves box to 0,0 after waiting
.then {
    self.box.frame.origin = CGPoint(x:0, y:0)
}
// displays message after all animations are done
.callback {
    print("Just finished moving šŸ“¦ around.")
}

It supports a bunch of easing functions and chaining multiple animations. It's a wrapper on Apple's UIViewPropertyAnimator on its core, and falls back to UIView.animate on versions before iOS and tvOS 10. It uses NSAnimationContext on macOS.

Examples

Example projects are available at examples/ folder and as targets on XCode project.

Bonfire

Profile

Menu

Message


Installation

Cocoapods

pod 'anim'

Carthage

github "onurersel/anim"

Manually

Or simply drag the swift files inside src/ folder into your project.


API

For complete documentation, visit http://onurersel.github.io/anim/.

Initialize animations with anim constructor.

// Initialize with default settings
anim {
    // animation block
}
// or initialize with it's own settings
anim { (settings) -> (animClosure) in
    settings.delay = 1
    settings.duration = 0.7
    settings.ease = .easeInOutBack

    return {
        // animation block
    }
}
// or initialize layout constraint animations just by passing the parent view
anim(constraintParent: self.view) {
    // animation block
}

anim(constraintParent: self.view) { (settings) -> (animClosure) in
    // settings...
    return {
        // animation block
    }
}

// you don't need to call layoutIfNeeded() before or inside the
// animation blocks, it's handled by anim
//
// for example to update constant value of a constraint,
// you can just change it inside the animation block
let width: NSLayoutConstraint //...
anim(constraintParent: self.view) {
    width.constant = 100 // new value
}
// that's it!

Chain animations with then function.

anim {}
.then{
    // next animation block
}
anim {}
.then { (settings) -> animClosure in
    settings.duration = 1
    return {
        // next animation block
    }
}
anim {}
.then(constraintParent: self.view) {
    // chaining constraint animations
}
.then(constraintParent: self.view) { (settings) -> animClosure in
    settings.duration = 1
    return {
        // next animation block for constraints
    }
}

Wait between animation steps with wait function.

anim{}.wait(0.25).then{} //...

Insert callbacks between animation steps with .callback function.

anim{}
.callback {
    // custom block
}
.then{} //...

Stop animations with stop function.

let animation = anim{}.then{} // ...
animation.stop()

Default settings

You can change default animation settings through anim.defaultSettings property.

anim.defaultSettings.ease = .easeInOutCubic

Easing

anim.Ease exposes a bunch of easing options.


License

anim is released under the MIT license. See LICENSE for details.

You might also like...
Easy animation library on iOS with Swift2
Easy animation library on iOS with Swift2

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

A radical & elegant animation library for iOS.
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

This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController.
This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController.

This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController. Installation Just add the Sources folder to your

A fantastic Physical animation library for swift
A fantastic Physical animation library for swift

A fantastic Physical animation library for swift(Not Just Spring !!!), it is base on UIDynamic and extension to it, friendly APIs make you use it or c

An Objective-C animation library used to create floating image views.
An Objective-C animation library used to create floating image views.

JRMFloatingAnimation [![CI Status](http://img.shields.io/travis/Caroline Harrison/JRMFloatingAnimation.svg?style=flat)](https://travis-ci.org/Caroline

Anima is chainable Layer-Based Animation library for Swift5.
Anima is chainable Layer-Based Animation library for Swift5.

Anima Anima is chainable Layer-Based Animation library for Swift5. It support to make sequensial and grouped animation more easily. is written as foll

Lightweight animation library for UIKit
Lightweight animation library for UIKit

MotionAnimation Lightweight animation library for UIKit in Swift Checkout the Examples folder for more. Consider MotionAnimation as a extremely simpli

Widgets iOS 14 animation with 3D and dynamic shadow. Customisable transform and duration.
Widgets iOS 14 animation with 3D and dynamic shadow. Customisable transform and duration.

SPPerspective About Animatable widgets from iOS 14. Same animation for transform and shadow. Customisable duration, perspective and shadow also. For v

This library for animating text. Developed with SwiftUI. This library supports iOS/macOS.

AnimateText This library for animating text. Developed with SwiftUI. This library supports iOS/macOS. Screenshot AnimateText.mp4 Example https://fabul

Comments
  • Bugfix: Command failed due to signal: Segmentation fault: 11

    Bugfix: Command failed due to signal: Segmentation fault: 11

    Following error occurred when Carthage trying to compile in release mode with Xcode 9.3:

    While silgen emitConstructor SIL function "@_T04anim0A8SettingsVACSd5delay_Sd8durationAA0A4EaseV4easeyycSg10completionSb25isUserInteractionsEnabledtcfC".
     for 'init(delay:duration:ease:completion:isUserInteractionsEnabled:)' at /Users/tengfoung/Developments/resi-mobile-ios/Carthage/Checkouts/anim/src/Settings.swift:11:15
    

    This PR fix the compilation issue.

    opened by tengfoung 2
  • 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 0
Owner
Onur Ersel
Onur Ersel
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
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
This repo contains swift collection of gui, games, menu, animations, music, payment, etc... for iOS, macOS, watchOS and tvOS

Swift-Collections About: This repo contains a collection of projects built using swift and objective-c Contains projects for macOS iOS iPad watchOS tv

Krisna Pranav 6 Nov 15, 2022
Physics-based animations for iOS, tvOS, and macOS.

Advance An animation library for iOS, tvOS, and macOS that uses physics-based animations (including springs) to power interactions that move and respo

Tim Donnelly 4.5k Dec 29, 2022
An elegant and flexible tweening library for iOS and tvOS.

PMTween is an elegant and flexible tweening library for Objective-C, currently supporting the iOS and tvOS platforms. It offers sensible default funct

Brett Walker 349 Nov 25, 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
A powerful, elegant, and modular animation library for Swift.

MotionMachine provides a modular, powerful, and generic platform for manipulating values, whether that be animating UI elements or interpolating prope

Brett Walker 387 Dec 9, 2022
Animation library for iOS in Swift

TweenKit TweenKit is a powerful animation library that allows you to animate (or 'tween') anything. TweenKit's animations are also scrubbable, perfect

Steve Barnegren 1.3k Dec 18, 2022