Created
December 26, 2013 14:02
-
-
Save ondrejmirtes/8134202 to your computer and use it in GitHub Desktop.
Animate sequence of animations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface AnimateSequence : NSObject | |
+ (void)animate:(NSArray*)blocks duration:(NSTimeInterval)duration; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AnimateSequence.h" | |
@implementation AnimateSequence | |
+ (void)animate:(NSArray*)blocks duration:(NSTimeInterval)duration | |
{ | |
[AnimateSequence animate:blocks duration:duration index:0]; | |
} | |
+ (void)animate:(NSArray *)blocks duration:(NSTimeInterval)duration index:(NSUInteger)i | |
{ | |
if (i >= blocks.count) { | |
return; | |
} | |
[UIView animateWithDuration:duration animations:[blocks objectAtIndex:i] completion:^(BOOL finished) { | |
[AnimateSequence animate:blocks duration:duration index:(i + 1)]; | |
}]; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)bounce | |
{ | |
NSMutableArray* blocks = [NSMutableArray new]; | |
[blocks addObject:^{ | |
[self.contentScrollView setContentOffset:(CGPoint){34.0, 0.0}]; | |
}]; | |
[blocks addObject:^{ | |
[self.contentScrollView setContentOffset:(CGPoint){self.closedXOffset, 0.0}]; | |
}]; | |
[blocks addObject:^{ | |
[self.contentScrollView setContentOffset:(CGPoint){12.0, 0.0}]; | |
}]; | |
[blocks addObject:^{ | |
[self.contentScrollView setContentOffset:(CGPoint){self.closedXOffset, 0.0}]; | |
}]; | |
[AnimateSequence animate:blocks duration:0.11f]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment