Animate easy and with less code with Swift

Overview

BuddyBuild codebeat badge Version Platform Swift3 License CocoaPods CocoaPods

JDAnimationKit is designed to be extremely easy to use. You can animate your UI withe less lines of code. This library use internally POP framework, an extensible iOS and OS X animation library, useful for physics-based interactions.

Supported OS & SDK Versions

  • iOS 8.0+
  • Swift 3 (JDAnimationKit 1.0.x), Swift 2.3 (JDAnimationKit 1.1.x)

Demo

Preview Preview

Beetripper App's screenshots

Installation

JDAnimationKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "JDAnimationKit"

Note: Due to CocoaPods/CocoaPods#4420 issue there is problem with compiling project with Xcode 7.1 and CocoaPods v0.39.0. However there is a temporary workaround for this: Add next lines to the end of your Podfile

post_install do |installer|
  `find Pods -regex 'Pods/pop.*\\.h' -print0 | xargs -0 sed -i '' 's/\\(<\\)pop\\/\\(.*\\)\\(>\\)/\\"\\2\\"/'`
end

To install manually the JDAnimationKit class in an app, just drag the JDAnimationKit.swift class file (demo files and assets are not needed) into your project. Also you need to install facebook-pop. Or add bridging header if you are using CocoaPods.

Usage

Import JDAnimationKit in proper place.

import JDAnimationKit

You can animate CALayers and UIViews (and subclasses). Only you add the animation you want after element.

self.squareView.rotateTo(90)

If you want mutiple animation at one time.

self.squareView.rotateTo(90).moveXBy(50).opacityTo(0)

All methods have got more arguments with default values. You don't need indicate all, only the params that your need.

self.squareView.rotateTo(90).moveXBy(50, delay: 2.0, timing: .EaseIn)

Configure your animations

You can adjust the parameters of your animations:

-> duration : Double

Indicate the duration of animation (Default: 0.5)

-> spring : Bool

Indicate if apply physics effects to animate (Default: false)

-> springConfig : JDSpringConfig (struct)

If spring property is true, configure the physics params (bounciness and speed) (Default: bounciness: 10, speed: 10)

-> timing : JDTimingFunction (enum)

The animation-timing-function specifies the speed curve of an animation (Default: .None)

Values:

  • EaseIn
  • EaseOut
  • EaseInOut
  • Linear
  • None

-> delay : Double

You can execute the animation after X seconds. (Default: 0)

-> key : String

Identify the animation

Anchoring

The anchor point represents the point from which certain coordinates originate. The anchor point is one of several properties that you specify using the unit coordinate system. Core Animation uses unit coordinates to represent properties whose values might change when the layer’s size changes. You can think of the unit coordinates as specifying a percentage of the total possible value. Every coordinate in the unit coordinate space has a range of 0.0 to 1.0. For example, along the x-axis, the left edge is at the coordinate 0.0 and the right edge is at the coordinate 1.0.

Preview

You can set the anchor point with this code:

self.squareView.changeAnchorPoint(0, y: 0)  

Callback

If you want to get animations callbacks or if you want to run code after an animation finishes, you are supposed to call didStopAnimation or didStartAnimation block.

self.squareView.scaleTo(2, scaleY: 2).didStartAnimation { (node, key, finished, error) -> Void in

}
self.squareView.scaleTo(2, scaleY: 2).didStopAnimation { (node, key, finished, error) -> Void in

}

Chainable Animations

self.squareView.moveXTo(100)
self.squareView.moveYTo(100)
self.squareView.moveTo(100, y: 100)
self.squareView.moveXBy(100)
self.squareView.moveYBy(50)
self.squareView.moveBy(100, deltaY: 50)
self.squareView.scaleXTo(2)
self.squareView.scaleYTo(2)
self.squareView.scaleTo(2, scaleY: 2)
self.squareView.opacityTo(0)
self.squareView.rotateTo(90)
self.squareView.changeBounds(bounds) //let bounds: CGRect
self.squareView.changeBgColor(green) //let green: UIColor

Author

License

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

You might also like...
⛓ Easy to Read and Write Multi-chain Animations Lib in Objective-C and Swift.
⛓ Easy to Read and Write Multi-chain Animations Lib in Objective-C and Swift.

中文介绍 This project is inspired by JHChainableAnimations! Why Choose LSAnimator & CoreAnimator? You can write complex and easy-to-maintain animations in

Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.
Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.

Twinkle ✨ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate

MGFlipView allows to create flipping view in easy way without worrying about flipping animation and flipping logic.
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

LottieUI - A library developed to make Lottie easy to implement. It supports iOS and macOS

LottieUI It is a library developed to make Lottie easy to implement. It supports

A UICollectionViewLayout subclass that adds custom transitions/animations to the UICollectionView without effecting your existing code.
A UICollectionViewLayout subclass that adds custom transitions/animations to the UICollectionView without effecting your existing code.

AnimatedCollectionViewLayout Normally a UICollectionView has no transition effects when you scroll from one item to another. There are lots of ways to

Design-system-demo - This example code is bare-bones to show you what this framework can do

Basic Style Dictionary This example code is bare-bones to show you what this fra

RAProgressRing is the simplest approach to bringing circular progress in your application with minimal code.
RAProgressRing is the simplest approach to bringing circular progress in your application with minimal code.

RAProgressRing RAProgressRing is the simplest approach to bringing circular progress in your application with minimal code. Features It's customisable

A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code.

SimpleAFLoader A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code. All animations are built using the SwiftUI

A DSL to make animation easy on iOS with Swift.
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

Comments
Releases(1.1)
Owner
Jelly Development
Jelly Development
(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
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
Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions. Every animation is randomized. Currently supported animations:

Artur Rymarz 23 Aug 23, 2022
WifiView Pod can animate wifi signal strength

WifiView WifiView is animateable UIView that can significantly enhance your users’ experiences and set your app apart from the rest of the pack. It is

Jawad Ali 12 Sep 27, 2022
jasu 29 Dec 20, 2022
365-day-of-code - This repository has been opened for 365 days to code iOS with Swift

365 day of code This repository has been opened for 365 days to code iOS with Sw

Mehmet ateş 17 Jan 3, 2023
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.

LoadingShimmer An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. Thi

Jogendra 1.4k Jan 6, 2023
Easy to read and write chainable animations in Objective-C and Swift

Whats new in version 3.x? Swiftier syntax Swift 4 support Bug fixes and improvements Whats new in version 2.x? Re-architected from the ground up, no m

Jeff Hurray 3.2k Dec 30, 2022