AIAnimation 0.0.2

AIAnimation 0.0.2

测试已测试
Lang语言 Obj-CObjective C
授权协议 MIT
Released最新发布2014年12月

Alejandro Isaza维护。



  • Alejandro Isaza

AIAnimation简化了与UIKit动画的工作,通过将动画视为第一类市民。您可以传递动画作为参数,从方法返回它们,并轻松链接多个动画。

示例

假设您有一个要在其父视图中移动的视图。动画分解成4个部分,然后使用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];

这比使用4个嵌套的块简单得多。

安装

只需将AIAnimation.[h,m]和AIAnimationSequence.[h,m]添加到您的项目中。如果您正在使用CocoaPods,请将此添加到您的Podfile中

pod 'AIAnimation'