All Projects → satoshin21 → Anima

satoshin21 / Anima

Licence: mit
Anima is chainable Layer-Based Animation library for Swift5.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Anima

Tkrubberindicator
A rubber animation pagecontrol
Stars: ✭ 1,337 (+165.28%)
Mutual labels:  coreanimation
Dwanimatedlabel
An UILabel subclass that lets you animate text with different types
Stars: ✭ 252 (-50%)
Mutual labels:  coreanimation
SwimplyPlayIndicator
Animated PlayIndicator written in SwiftUI. Inspired by Apple's Music Player.
Stars: ✭ 52 (-89.68%)
Mutual labels:  coreanimation
Core Animation Pie Chart
Pie Chart built using CAShapeLayers, a CADisplayLink and custom layer properties
Stars: ✭ 107 (-78.77%)
Mutual labels:  coreanimation
Axanimationchain
AXAnimationChain is a chain animation library, can be used to easily create CAAnimation based chain animation. There are two kinds of combination chain, one is called combination, the other is called link, created by the two ways above, the animation can be carried out at the same time, can also according to the time order, you can use the code to create a rich and complex animation.
Stars: ✭ 234 (-53.57%)
Mutual labels:  coreanimation
UberAnimation
Heyaa! This is an attempt to mimic the animation Uber and Facebook shows up as a Congratulatory Pop-up. Looking at the attached GIF will give you a better idea of what this project covers. All written in Swift4.
Stars: ✭ 58 (-88.49%)
Mutual labels:  coreanimation
Progressbutton
Custom ProgressButton
Stars: ✭ 52 (-89.68%)
Mutual labels:  coreanimation
Ttgemojirate
An emoji-liked rating view for iOS, implemented in Swift3.
Stars: ✭ 284 (-43.65%)
Mutual labels:  coreanimation
Core Animation Fun House
Core Animation Examples (Basics, Replicator, Reflection, Wiggle Jiggle, Lissajous Curve, Sine Wave, etc.)
Stars: ✭ 249 (-50.6%)
Mutual labels:  coreanimation
SHTransition
SHTransition is a simple library for viewcontroller transition animation in swift.
Stars: ✭ 35 (-93.06%)
Mutual labels:  coreanimation
Imagineengine
A project to create a blazingly fast Swift game engine that is a joy to use 🚀
Stars: ✭ 1,751 (+247.42%)
Mutual labels:  coreanimation
Decomposed
CATransform3D manipulation made easy.
Stars: ✭ 184 (-63.49%)
Mutual labels:  coreanimation
FluentTransitions
▶ Smooth UI animations & transitions for .NET
Stars: ✭ 27 (-94.64%)
Mutual labels:  coreanimation
Facebookpoptest
动画实现的一些常见功能及实现方式,不断更新中....
Stars: ✭ 99 (-80.36%)
Mutual labels:  coreanimation
YTAnimation
iOS动画集锦, swift, 核心动画, 基础动画,关键帧动画, 组动画, 过渡动画, 进度条,项目案例.
Stars: ✭ 60 (-88.1%)
Mutual labels:  coreanimation
Learniosanimations
Learn iOS Animations
Stars: ✭ 66 (-86.9%)
Mutual labels:  coreanimation
CircleFlow
CircleFlow is a project that revises Coverflow effect. Using Core Animation to build Coverflow-like effect but with a half-circle path
Stars: ✭ 39 (-92.26%)
Mutual labels:  coreanimation
Stepslider
StepSlider its custom implementation of slider such as UISlider for preset integer values.
Stars: ✭ 391 (-22.42%)
Mutual labels:  coreanimation
VKProgressHud
Hey All! As it is obvious from the GIF, this project is a LoadingIndicator based on CoreAnimation.
Stars: ✭ 30 (-94.05%)
Mutual labels:  coreanimation
lotus
A Swift animation DSL for animating layers with help of CoreAnimation
Stars: ✭ 15 (-97.02%)
Mutual labels:  coreanimation

Version License Platform language Version Build Status MIT License Platform Carthage compatible

Anima

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

is written as follows.

let startAnimations: [AnimaType] = [.moveByY(-50), .rotateByZDegree(90)]
let moveAnimations: [AnimaType] = [.moveByX(50), .rotateByZDegree(90)]
let endAnimations: [AnimaType] = [.moveByY(-50), .rotateByZDegree(90)]

animaView.layer.anima
    .then(.opacity(1.0))
    .then(group: startAnimations)
    .then(group: moveAnimations, options: labelAnimaOption(index: 0))
    .then(group: moveAnimations, options: labelAnimaOption(index: 1))
    .then(group: moveAnimations, options: labelAnimaOption(index: 2))
    .then(group: moveAnimations, options: labelAnimaOption(index: 3))
    .then(group: endAnimations, options: labelAnimaOption(index: 4))
    .then(group: [.scaleBy(0.0), .opacity(0.0)])

func labelAnimaOption(index: Int) -> [AnimaOption] {
    let labelAnima = labels[index]?.layer.anima

    return [.completion({
        labelAnima?.then(.opacity(1)).fire()
    })]
}

Requirements

Anima require for Swift4 and greater than iOS9.0📱

Features

  • Almost all timing modes from easings.set are implemented.
  • Spring Animation ( featured by CASpringAnimation )
  • Type-Safed Animation KeyPath ()

Usage

Move Position

If you want to translate CALayer.position relatively, use .moveByX(CGFloat), .moveByY(CGFloat), .moveByXY(x: CGFloat, y: CGFloat) AnimaTypes.

layer.anima.then(.moveByX(50)).fire()

or destination is determined, use .moveTo(x: CGFloat, y: CGFloat).

※ Anima doesn't update CALayer.position value for animations. Because when update Layer-backed view's layer position value, It will be resetted to default value frequently.

Sequential Animation

Anima supports.

Group Animation

To run animation concurrently, you use CAAnimationGroup with CoreAnimation. In Anima, you can use Anima.then(group: ) to run some AnimaType concurrently.

Below is an example of how to run moving, scaling and rotating animations concurrently.

layer.anima
    .then(group: [.moveByX(200),
                .scaleBy(1.5),
                .rotateByZDegree(180)])
    .fire()

Animation Options

There are some options for Anima.

  • duration(TimeInterval)
  • timingFunction(TimingFunction) _ Change timing function defining the pacing of the animation. _ Default timing function is at Anima.defaultTimingFunction. If you do not set the timing function option, defaultTimingFunction is used. * Please read Anima.TimingFunction.swift
  • repeat(count: Float) * To run animation infinitely, set .infinity.
  • autoreverse
  • completion(() -> Void)

you can use these values as belows.

layer
    .anima
    .then(.moveByX(100), options: [.autoreverse,
                                   .timingFunciton(.easeInQuad),
                                   .repeat(count: 3),
                                   .completion({
                                    print("completion")
                                   })])
    .fire()

Rotate Animation & AnchorPoint

AnimaType has 3 rotation animation type, .rotateByX, .rotateByY, .rotateByZ. and each animation type has 2 value types, degrees and radians. you use whichever you like.

and CALayer has AnchorPoint. Rotating, moving, or other Animations are affected by it. Default value is (0.5, 0.5). AnimaType.moveAnchor(AnimaAnchorPoint) can move layer's AnchorPoint.

layer.anima
    .then(.rotateByZDegree(360))
    .then(.moveAnchor(.topLeft))
    .then(.rotateByZDegree(360))
    .fire()

or If you want to change only AnchorPoint, use Anima.then(setAnchor: AnimaAnchorPoint).

layer.anima
    .then(.rotateByZDegree(360))
    .then(setAnchor: .topLeft)
    .then(.rotateByZDegree(360))
    .fire()

Move Path

If you want to make moving animation more complex, use .movePath(path: CGPath, keyTymes: [Double]). Anima example app has sample of creating animation by drag gesture. you see it!

but It has any problems when you use with AnimaOption.autoreverse. so If you use it, please be careful of options.

Original KeyPath

If you want to animate other animatable values, You can use AnimaType.original(keyPath: String, from: Any?, to: Any) for it. CAEmitterLayer's animation is like this.

let layer = CAEmitterLayer()
layer.emitterPosition = CGPoint(x: 100.0, y:100.0)

layer.anima
    .then(.original(keyPath: #keyPath(CAEmitterLayer.emitterPosition), from: layer.emitterPosition, to: CGPoint(x: 200.0, y:200.0)))
    .fire()

Example

To run the example project, clone the repo, open Anima.xcodeproj, and run target Anima iOS Example.

Installation

Cocoapods

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

pod "Anima"

# If you want to use Swift 3 version, Please specify Anima version.

pod "Anima", "0.5.1"

Carthage

Add github satoshin21/Anima to your Cartfile. Execute carthage update to install it.

Author

Satoshi Nagasaka, [email protected]

License

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

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].