Skip to content

Instantly share code, notes, and snippets.

@codeswimmer
Created January 2, 2013 19:54
Show Gist options
  • Select an option

  • Save codeswimmer/4437387 to your computer and use it in GitHub Desktop.

Select an option

Save codeswimmer/4437387 to your computer and use it in GitHub Desktop.
iOS: How to create an animation with a series of images
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