2009-10-05

How to create a sequence of images animated in an iPhone application.

    NSArray *myImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"test.png"], [UIImage imageNamed:@"buddha.jpg"], nil];
    UIImageView *myAnimatedView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    [myAnimatedView initWithFrame:[self.view bounds]];
    myAnimatedView.animationImages = myImages;
    myAnimatedView.animationDuration = 0.25; // seconds
    myAnimatedView.animationRepeatCount = 0; // 0 = loops forever
    [myAnimatedView startAnimating];
    [self.view addSubview:myAnimatedView];
    [myAnimatedView release];

No comments: