All Projects → alejandro-isaza → AIAnimation

alejandro-isaza / AIAnimation

Licence: MIT license
UIKit animations as first-class citizens -- make animations easier to manipulate.

Programming Languages

objective c
16641 projects - #2 most used programming language

AIAnimation

Build Status

AIAnimation makes working with UIKit animations simpler by making animations first-class citizens. You can pass animations as arguments, return them from methods and easily chain animations together.

Example

Suppose you have a view you want to move around its parent. The animation is broken down into 4 parts and then chained together with an AIAnimationSequence:

AIViewController __weak* wself = self;
CGSize containerSize = _animationContainerView.bounds.size;
CGSize blockSize = _animatingView.bounds.size;

AIAnimation* animation1 = [AIAnimation animationWithDuration:0.25 block:^() {
    wself.animatingView.center = CGPointMake(blockSize.width/2, containerSize.height - blockSize.height/2);
}];

AIAnimation* animation2 = [AIAnimation animationWithDuration:0.25 block:^() {
    wself.animatingView.center = CGPointMake(containerSize.width - blockSize.width/2, containerSize.height - blockSize.height/2);
}];

AIAnimation* animation3 = [AIAnimation animationWithDuration:0.25 block:^() {
    wself.animatingView.center = CGPointMake(containerSize.width - blockSize.width/2, blockSize.height/2);
}];

AIAnimation* animation4 = [AIAnimation animationWithDuration:0.25 block:^() {
    wself.animatingView.center = CGPointMake(blockSize.width/2, blockSize.height/2);
}];

_animationSequence = [AIAnimationSequence animationSequenceWithAnimations:@[ animation1, animation2, animation3, animation4 ]];
_animationSequence.repeat = YES;
[_animationSequence run];

That's simpler than having 4 nested blocks.

Installation

Just add AIAnimation.[h,m] and AIAnimationSequence.[h,m] to your project. If you are using CocoaPods, add this to your Podfile:

pod 'AIAnimation'
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].