Code Monkey home page Code Monkey logo

dcanimationkit's Introduction

DCAnimationKit

A collection of animations for iOS Simply, just add water! DCAnimationKit is a category on UIView to make animations easy to perform.

Examples

All our examples will use this as a base.

self.moveLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 85, 200, 100)];
self.moveLabel.backgroundColor = [UIColor clearColor];
self.moveLabel.text = NSLocalizedString(@"Animate!", nil);
self.moveLabel.font = [UIFont systemFontOfSize:36];
[self.moveLabel sizeToFit];
[self.view addSubview:self.moveLabel];

self.moveView = [[UIView alloc] initWithFrame:CGRectMake(40, 165, 200, 100)];
self.moveView.backgroundColor = [UIColor orangeColor];
[self.view addSubview:self.moveView];

Attention getters

Tada

alt tag

our method to run tada.

[self.moveView tada:NULL];
[self.moveLabel tada:NULL];

Bounce

alt tag

our method to run bounce.

[self.moveView bounce:NULL];
[self.moveLabel bounce:NULL];

Pulse

alt tag

our method to run pulse.

[self.moveView pulse:NULL];
[self.moveLabel pulse:NULL];

Shake

alt tag

our method to run shake.

[self.moveView shake:NULL];
[self.moveLabel shake:NULL];

Swing

alt tag

our method to run swing.

[self.moveView swing:NULL];
[self.moveLabel swing:NULL];

Intros

Intros have a slight difference from the base code. We simple remove these 2 lines:

//[self.view addSubview:self.moveLabel];
//[self.view addSubview:self.moveView];

This lines will be added to the view once they snap in.

Snap

alt tag

our method to run the snap in.

[self.moveLabel snapIntoView:self.view direction:DCAnimationDirectionTop];
[self.moveView snapIntoView:self.view direction:DCAnimationDirectionLeft];

Bounce

alt tag

our method to run the bounce in.

[self.moveLabel bounceIntoView:self.view direction:DCAnimationDirectionTop];
[self.moveView bounceIntoView:self.view direction:DCAnimationDirectionLeft];

Expand

alt tag

our method to run the expand.

[self.moveLabel expandIntoView:self.view finished:NULL];
[self.moveView expandIntoView:self.view finished:NULL];

Outros

Compress

alt tag

our method to run the compress.

[self.moveLabel expandIntoView:NULL];
[self.moveView expandIntoView:NULL];

Hinge

alt tag

our method to run the hinge.

[self.moveLabel hinge:NULL];
[self.moveView hinge:NULL];

Drop

alt tag

our method to run the drop.

[self.moveLabel drop:NULL];
[self.moveView drop:NULL];

General transitions

To round off our fantastic animations, DCAnimationKit also simplifies doing ordinary frame manipulation.

UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(40, 85, 50, 50)];
baseView.backgroundColor = [UIColor grayColor];
[self.view addSubview:baseView];

self.moveView = [[UIView alloc] initWithFrame:baseView.frame];
self.moveView.backgroundColor = [UIColor redColor];
[self.view addSubview:self.moveView];

Move

alt tag

our code to move around.

CGFloat distance = 80;
__weak id weakSelf = self.moveView;
[weakSelf moveX:distance finished:^{
    [weakSelf moveY:distance finished:^{
        [weakSelf moveX:-distance finished:^{
            [weakSelf moveY:-distance finished:^{

            }];
        }];
    }];
}];

We can also set the view's origin to a specific value as well.

__weak id weakSelf = self.moveView;
[weakSelf setX:200 finished:^{
    [weakSelf setY:200 finished:^{
        [weakSelf setX:40 finished:^{
            [weakSelf setY:85 finished:^{

            }];
        }];
    }];
}];

We can even slide to a specific point (there is a move as well!).

[self.moveView movePoint:CGPointMake(100, 100) finished:NULL];

Rotation

alt tag

our code to rotate (there is a move rotation as well).

__weak id weakSelf = self.moveView;
[weakSelf setRotation:45 duration:.35 finished:^{
    [weakSelf setRotation:0 duration:.35 finished:^{

    }];
}];

Install

The recommended approach for installing DCAnimationKit is via the CocoaPods package manager, as it provides flexible dependency management and dead simple installation.

via CocoaPods

Install CocoaPods if not already available:

$ [sudo] gem install cocoapods
$ pod setup

Change to the directory of your Xcode project, and Create and Edit your Podfile and add DCAnimationKit:

$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
platform :ios, '7.0'
pod 'DCAnimationKit'

Install into your project:

$ pod install

Open your project in Xcode from the .xcworkspace file (not the usual project file)

Requirements

DCAnimationKit requires at least iOS 7 or above.

License

DCAnimationKit is license under the Apache License.

Contact

Dalton Cherry

dcanimationkit's People

Contributors

daltoniam avatar acmacalister avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.