Skip to content

0xc00010ff/UIView-SequentialAnimation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

UIView-SequentialAnimation

A UIView category method that provides a simple declarative API for scheduling a sequence of animations

Methods:

+ (void)animateViews:(NSArray*)views
        withDuration:(double)duration
          animations:(void(^)(UIView*, NSInteger))animationBlock;
+ (void)animateViews:(NSArray*)views
        withDuration:(double)duration
          animations:(void(^)(UIView*, NSInteger))animationBlock
          completion:(void(^)(void))completionBlock;
+ (void)animateViews:(NSArray*)views
        withDuration:(double)duration
          animations:(void(^)(UIView*, NSInteger))animationBlock
      eachCompletion:(void(^)(UIView*, NSInteger))iterationCompletionBlock
          completion:(void(^)(void))completionBlock;
+ (void)animateViews:(NSArray*)views  
        withDuration:(double)duration  
               delay:(double)delay      
          animations:(void(^)(UIView*, NSInteger))animationBlock
      eachCompletion:(void(^)(UIView*, NSInteger))iterationCompletionBlock
          completion:(void(^)(void))completionBlock 
             options:(UIViewAnimationOptions)animationOptions;

Breaking down the parameters:

animateViews:(NSArray*)views The views that will be animated. The order of the views is the order in which the animations will occur.

withDuration:(double)duration The duration of each individual view animation.

delay:(double)delay The delay between each individual animation. A negative value will have the next animation fire before the previous is completed, and a negative number with a value that equals the duration will cause all animations to happen synchronously.

animations:(void(^)(UIView* view, NSInteger iteration))animationBlock The animations to be performed on each view. Use the supplied view parameter for all animations. iteration is the current index of the view being animated.

eachCompletion:(void(^)(UIView*, NSInteger))iterationCompletionBlock A block that is called at the end of each individual animation's completion. Not animated by default.

completion:(void(^)(void))completionBlock A block that is called only after all animations have completed.

options:(UIViewAnimationOptions)animationOptions UIViewAnimationOptions for speed curves, autoreversing, and so on.

Simple example:

'Pop' (inflate/deflate) a set of views.
    [UIView animateViews:arrayOfViews
            withDuration:0.25
                   delay:-0.1
              animations:^(UIView * view, NSInteger iteration) 
              {
                  // Enlarge the views's layer
                  CGFloat scaleDelta = 1.5f;
                  CATransform3D scaleTransform = CATransform3DMakeScale(scaleDelta, scaleDelta, 1.0);
                  view.layer.transform = scaleTransform;
              }
              eachCompletion:^(UIView * view, NSInteger iteration) 
              {
                // Return the view to it's original size
                [UIView animateWithDuration:duration animations:^{
                    CATransform3D scaleTransform = CATransform3DIdentity;
                    view.layer.transform = scaleTransform;
                }];
             }     
             completion:^
             {
                NSLog(@"Wow. So animation. Very abstraction.");
             } 
             options:UIViewAnimationOptionCurveEaseOut];

About

Category on UIView that schedules sequential animations for an array of views.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published