Tuesday, September 21, 2010

Simple Animation using a series of Images

NSArray *myImages = [NSArray arrayWithObjects:

[UIImage imageNamed:@"myImage1.png"],

[UIImage imageNamed:@"myImage2.png"],

[UIImage imageNamed:@"myImage3.png"],
[UIImage imageNamed:@"myImage4.gif"], nil]; // series of images that you want to animate

UIImageView *myAnimatedView = [UIImageView alloc];

[myAnimatedView initWithFrame:[self bounds]];

myAnimatedView.animationImages = myImages;

myAnimatedView.animationDuration = 0.25;     // time in seconds

 myAnimatedView.animationRepeatCount = 0;     // 0 = loops forever




[myAnimatedView startAnimating];

[self addSubview:myAnimatedView];

[myAnimatedView release];

No comments:

Post a Comment