UIKit animations as first-class citizens -- make animations easier to manipulate.
Objective-C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
AIAnimation.xcodeproj
AIAnimation
AIAnimationExample
AIAnimationTests
.gitignore
.travis.yml
LICENSE
README.md

README.md

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'