ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - icanzilb/EasyAnimation: A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together! - ic...
Visit Site

GitHub - icanzilb/EasyAnimation: A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!

GitHub - icanzilb/EasyAnimation: A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!

ver 2.0

NB! Breaking changes in 2.0 - due to a lot of requests EasyAnimation does NOT automatically install itself when imported. You need to enable it by calling EasyAnimation.enable() somewhere in your code (AppDelegate is a good idea).

The library doesn't use any private APIs - apps using it should be fine for release on the App Store.

Intro

UIView.animateWithDuration:animations: is really easy to use and you're so familiar with its syntax that you often want it to do just a bit more for you automatically. But it doesn't and you need to import Bloated.framework by Beginner Ninja Coder in order to make a bit more advanced animations than what animateWithDuration:animations: allows you to.

EasyAnimation extends what UIKit offers in terms of animations and makes your life much easier because you can do much more without learning some perky new syntax.

In version 2.0 and higher to enable all EasyAnimation features you need to run once this code - AppDelegate is a good place since it'll enable EasyAnimation as soon as your app starts.

In your other classes you don't need to import EasyAnimation or do anything else. Once you call enable() afterwards you use the normal UIKit APIs like usual.

Easy Layer Animations

EasyAnimation allows you to animate your layers straight from animate(duration:animations:...). No more CABasicAnimation code for you. Just adjust the properties of your layers from within the animations block and EasyAnimation will take care of the rest:

(OK, this example actually works fine also without EasyAnimation but I still keep it here for illustrative purpose)

Or if you need to specify delay, animation options and/or animation curve:

    // let's add more animations 
    // to make it more interesting!
    self.view.layer.cornerRadius = 20.0
    self.view.layer.borderWidth = 5.0
}, completion: nil)

And if you want to execute a piece of code after the animation is completed - good luck setting up your animation delegate and writing the delegate methods.

With EasyAnimation you just put your code as the completion parameter value and EasyAnimation executes it for you when your animation completes.

Spring Layer Animations

One thing I really missed since iOS9 when using CoreAnimation and CABasicAnimation was that there was no easy way to create spring animations. Luckily a handy library called RBBAnimation provides an excellent implementation of spring animations for layers - I translated the code to Swift and included RBBSpringAnimation into EasyAnimation.

Easy Animation takes care to use the new in iOS9 spring animation class CASpringAnimation when your app runs on iOS9 or higher and falls back to RBBSpringAnimation when your app runs on iOS8.

Here's how the code to create a spring animation for the layer position, transform and corner radius looks like:

Sam Davies collaborated on the spring animations code. Thanks a ton - I couldn't have figured this one on my own!

Chain Animations

animate(duration:animations:..) is really handy but chaining one animation after another is a major pain (especially if we are talking about more than 2 animations).

EasyAnimation allows you to use a method to just chain two or more animations together. Call animateAndChain(duration:delay:options:animations:completion:) and then chain to it more animations. Use animate(duration:animations...) or any other method to create chained animations.

Yes - that works, give it a try in your project :]

This code will animate the view along a rectangular path - first downwards, then to the right, then up, then to the initial point where the animation started.

What a perfect oportunity to repeat the animation and make the animation run continuosly! Add options parameter to the last animate(duration:... in the chain and turn on the .repeat option.

This will make the whole chain (e.g. the 4 animations) repeat continuously.

If you want to pause between any two animations in the chain - just use the delay parameter and it will all just work.

Note: animateAndChain does not create a serial queue to which you could add animations at any time. You schedule your animations once with one call like the example above and it runs on its own, you can't add or remove animations to and from the sequence.

Cancel Chain Animations

If you have a repeating (or a normal) chain animation on screen you can cancel it at any time. Just grab hold of the animation object and call cancelAnimationChain on it any time you want.

If you want to do some cleanup after the animation chain is cancelled provide a block of code to the cancelAnimationChain method:

The animation will not stop immediately but once it completes the current step of the chain it will stop and cancel all scheduled animations in this chain.

Installation

  • CocoaPods: Add to your project's Podfile:

pod 'EasyAnimation'

  • Carthage: If you can help with Cartage support let me know.

  • Source code: To install with the source code - clone this repo or download the source code as a zip file. Include all files within the EasyAnimation folder into your project.

Credit

Author: Marin Todorov

More about Marin:

Includes parts of RBBAnimation by Robert Böhnke. The code is translated from Objective-C to Swift by Marin Todorov.

Collaborator on the spring animation integration: Sam Davies.

License

EasyAnimation is available under the MIT license. See the LICENSE file for more info.

RBBAnimation license: https://github.com/robb/RBBAnimation/blob/master/LICENSE

To Do

  • .autoreverse for chain animations (if possible)
  • add support for keyframe animation along the path via a custom property

Version History

  • 2.0 - initialize() is deprecated so in need of manual initialization
  • 1.1 - Xcode 8
  • 1.0.5 - Xcode 7.3 compatibility
  • 1.0.4 - Swift 3 compatibility changes
  • 1.0.2 - Fixes openGL view crashes for everyone
  • 1.0.1 - Bug fixes
  • 1.0 - Swift 2.0 and iOS9
  • 0.7 - round of bug fixes and a number of improvements
  • 0.6 - first beta version

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory