tags:

views:

6

answers:

0

I want to get the current image in an animation, How can I do it?

    //Set up bottom view
    UIImageView *bottomView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 180, 50, 150)];
    bottomView.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"redLight.png"],
                                 [UIImage imageNamed:@"yellowLight.png"],
                                 [UIImage imageNamed:@"greenLight.png"],
                                 nil];
    [bottomView setAnimationDuration:5.0];
    //Set up top view
    UIImageView *topView = [[UIImageView alloc] initWithFrame:CGRectMake(230, 130, 50, 150)];
    topView.animationImages = [NSArray arrayWithObjects:
                                  [UIImage imageNamed:@"redLight.png"],
                                  [UIImage imageNamed:@"yellowLight.png"],
                                  [UIImage imageNamed:@"greenLight.png"],
                                  nil];
    [topView setAnimationDuration:5.0];
    topView.transform = CGAffineTransformMakeRotation(180.0 /180.0 * M_PI);

    [bottomView startAnimating];
    [topView startAnimating];
    [self.view addSubview:bottomView];
    [self.view addSubview:topView];

I tried using this but it doesnt seem to work..

if (bottomView.image == [UIImage imageNamed:@"greenLight.png"]) {
        isTimeToTap = YES;
    }
    [topView release];
    [bottomView release];