All Projects → rchatham → Swiftyanimate

rchatham / Swiftyanimate

Licence: mit
Composable animations in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftyanimate

Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+508.25%)
Mutual labels:  cocoapods, carthage, animations
Ssspinnerbutton
Forget about typical stereotypic loading, It's time to change. SSSpinnerButton is an elegant button with a diffrent spinner animations.
Stars: ✭ 357 (+84.02%)
Mutual labels:  cocoapods, carthage, animations
Kvkcalendar
A most fully customization calendar and timeline library for iOS 📅
Stars: ✭ 160 (-17.53%)
Mutual labels:  cocoapods, carthage
Forecastio
A Swift library for the Forecast.io Dark Sky API
Stars: ✭ 164 (-15.46%)
Mutual labels:  cocoapods, carthage
Ktvhttpcache
A powerful media cache framework.
Stars: ✭ 2,113 (+989.18%)
Mutual labels:  cocoapods, carthage
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-18.56%)
Mutual labels:  cocoapods, carthage
Zkudid
Generate and save permanent UDID with IDFV and keychain in iOS device.
Stars: ✭ 159 (-18.04%)
Mutual labels:  cocoapods, carthage
Multipeer
📱📲 A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices
Stars: ✭ 170 (-12.37%)
Mutual labels:  cocoapods, carthage
Sdl ios
Get your app connected to the 🚙, make your users feel like a 🌟
Stars: ✭ 147 (-24.23%)
Mutual labels:  cocoapods, carthage
Wkcookiewebview
WKWebView with cookie sharing support
Stars: ✭ 171 (-11.86%)
Mutual labels:  cocoapods, carthage
Cocoalumberjack
A fast & simple, yet powerful & flexible logging framework for Mac and iOS
Stars: ✭ 12,584 (+6386.6%)
Mutual labels:  cocoapods, carthage
Irldocumentscanner
A drop-in Objective-C ViewController that will Automatically scan a document for you you.
Stars: ✭ 172 (-11.34%)
Mutual labels:  cocoapods, carthage
Apesuperhud
A simple way to display a HUD with a message or progress information in your application.
Stars: ✭ 156 (-19.59%)
Mutual labels:  cocoapods, carthage
Underlinetextfield
Simple UITextfield Subclass with state
Stars: ✭ 156 (-19.59%)
Mutual labels:  cocoapods, carthage
Bluetonium
Bluetooth mapping in Swift
Stars: ✭ 159 (-18.04%)
Mutual labels:  cocoapods, carthage
Heapinspector For Ios
Find memory issues & leaks in your iOS app without instruments
Stars: ✭ 1,819 (+837.63%)
Mutual labels:  cocoapods, carthage
Bluetoothkit
Easily communicate between iOS/OSX devices using BLE
Stars: ✭ 2,027 (+944.85%)
Mutual labels:  cocoapods, carthage
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-8.76%)
Mutual labels:  cocoapods, carthage
Eureka
Elegant iOS form builder in Swift
Stars: ✭ 11,345 (+5747.94%)
Mutual labels:  cocoapods, carthage
Auth0.swift
Swift toolkit for Auth0 API
Stars: ✭ 146 (-24.74%)
Mutual labels:  cocoapods, carthage

Composable animations in Swift. Blog

Platform: iOS 8+ Language: Swift 3 License: MIT

Cocoapods compatible Carthage compatible SPM compatible

Docs Codecov Travis Code Climate

Installation

Cocoapods

The easiest way to get started is to use CocoaPods. Just add the following line to your Podfile:

pod 'SwiftyAnimate', '~> 1.3.0'

Carthage

github "rchatham/SwiftyAnimate"

Swift Package Manager

Add the following line to your Package.swift file.

.Package(url: "https://github.com/rchatham/SwiftyAnimate.git", majorVersion: 0) 

Usage

This library can be used to design composable animations while keeping animation code readable and maintainable.

Composing Animations

Compose animations and insert logic inbetween them using the then, do, and wait functions.

Then blocks

Add animations to the current instance using one of the implementations for this function. There are implemetations for spring and keyframe animations as well as chaining Animate objects together.

Animate(duration: 1.0) {
        // animation code goes here
    }
    .then(duration: 0.5) {
        // more animation code
    }
    .perform()

And blocks

Add animations to the current instance using one of the implementations for this function. There are implemetations for spring and keyframe animations as well as stacking Animate objects together. 'And' animations are performed in sync with the animation before it.

Animate(duration: 1.0) {
        // animation code goes here
    }
    .and(duration: 0.5) {
        // more animation code
    }
    .perform()

Do blocks

Add code that you don't intend on animating but would like to perform between animations here. Any code you put here will NOT be animated.

Animate(duration: 1.0) {
        // animation code goes here
    }
    .do {
        // logic you don't want to animate
    }
    .then(duration: 0.5) {
        // more animation code
    }
    .perform()

Wait blocks

Add code that you may want to pause an ongoing chain of animations for. Any code you put here will NOT be animated. You can pass in a timeout if you want to wait for a specific amount of time or if you don't want to wait longer to execute the code in the wait block.

Animate(duration: 1.0) {
        // animation code goes here
    }
    .wait(timeout: 5.0) { resume in
        // logic you want to pause an animation to complete
        resume()
    }
    .then(duration: 0.5) {
        // more animation code
    }
    .perform()

Performing Animations

There are two ways to perform animations finish and perform. Important: You must either call one of these two functions or decay on an animation instance or this will result in a memory leak!

Perform

This one is easy. Call this on an animation instance to perform it. Perform takes an optional closure which gets excecuted on completing the last animation block.

let animation = Animate(duration: 1.0) {
    // animations
}

animation.perform()

Finish

If you don't need to pass in a completion closure try calling finish on your animation instance. The animation passed in is enqueue'd and then perform is called on the instance. Finish has all of the same variations as the then function.

Animate(duration: 1.0) {
        // animations
    }
    .finish(duration: 1.0) {
        // animations
    }

Decay

If you would like to deallocate an animation instance without performing it call decay on it.

let animation = Animate(duration: 1.0) {
    // animations
}

animation.decay()

UIView Extensions

A number of animatable properties have extensions defined to make implementing them with this library even easier. Please check the docs!

Best Practices

The best way to take advantage of this library is define extensions for the views that you would like to animate. This compartmentailizes your code and keep all the animation logic tucked up within the view and out of your view controllers.

extension AnimatingView {
    func bounceAnimation() -> Animate {
        return Animate()
            .then(animation: scale(duration: 0.3, x: 1.3, y: 1.3))
            .then(animation: scale(duration: 0.3, x: 0.8, y: 0.8))
            .then(animation: scale(duration: 0.3, x: 1.1, y: 1.1))
            .then(animation: scale(duration: 0.3, x: 1.0, y: 1.0))
    }
}

Then when you go to perform an animation you just have to call perform() on the returned animation.

let animatingView = AnimatingView()

animatingView.bounceAnimation().perform()

And string them together with other animations for building up complex animation logic easily.

Animate()
    .then(animation: animatingView.bounceAnimation())
    .then(animation: animatingView.tiltAnimation())
    .then(animation: animatingView.bounceAnimation())
    .perform()

Contributing

I would love to see your ideas for improving this library! The best way to contribute is by submitting a pull request. I'll do my best to respond to your patch as soon as possible. You can also submit a new GitHub issue if you find bugs or have questions. 🙏

Please make sure to follow our general coding style and add test coverage for new features!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].