DCAnimationKit

iOS 动画集。简单,只需添加水动画。「A collection of animations for iOS. Simple, just add water animations.」

Github星跟蹤圖

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

主要指標

概覽
名稱與所有者daltoniam/DCAnimationKit
主編程語言Objective-C
編程語言Ruby (語言數: 2)
平台
許可證Apache License 2.0
所有者活动
創建於2014-03-21 15:37:15
推送於2016-02-09 09:42:42
最后一次提交2014-12-18 09:36:17
發布數6
最新版本名稱0.0.6 (發布於 2014-12-18 09:36:52)
第一版名稱0.0.1 (發布於 2014-03-25 08:41:39)
用户参与
星數804
關注者數34
派生數88
提交數17
已啟用問題?
問題數3
打開的問題數1
拉請求數0
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?