Created
January 2, 2013 19:54
-
-
Save codeswimmer/4437387 to your computer and use it in GitHub Desktop.
iOS: How to create an animation with a series of images
This file contains hidden or 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
| NSArray *myImages = [NSArray arrayWithObjects: | |
| [UIImage imageNamed:@"1.png"], | |
| [UIImage imageNamed:@"2.png"], | |
| [UIImage imageNamed:@"3.jpg"], | |
| [UIImage imageNamed:@"4.gif"], nil]; | |
| UIImageView *myAnimatedView = [UIImageView alloc]; | |
| [myAnimatedView initWithFrame:[self bounds]]; | |
| myAnimatedView.animationImages = myImages; | |
| myAnimatedView.animationDuration = 0.25; // seconds | |
| myAnimatedView.animationRepeatCount = 0; // 0 = loops forever | |
| [myAnimatedView startAnimating]; | |
| [self addSubview:myAnimatedView]; | |
| [myAnimatedView release]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment