Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi Guys,
I have this two frame animation running in a UIView:
Code:
    NSArray *animationFrames = [NSArray arrayWithObjects:
                                [UIImage imageNamed:@"Frame1.PNG"],
                                [UIImage imageNamed:@"Frame2.PNG"],
                                nil];
    
    myImageView = [[UIImageView alloc] init];
    myImageView.animationImages = animationFrames;
    myImageView.bounds = CGRectMake(0, 0, 50, 50);
    myImageView.animationDuration = 1.0;
    myImageView.animationRepeatCount = 0;
    [myImageView startAnimating];

It swaps frames every second forever fine.
Is there a way that I can later tell which frame is currently being shown?
I don't want, or need to interrupt it.

Any help appreciated :)
Cheers, Art.
 
Last edited:
Well I didn't find whatever is indexing the images, but you can set the loop to
run just once and start a timer when you start animating.
Then when the timer reaches the animation duration you can restart the timer
and the animation.

Then any time you can work out the animation frame by looking at the timer.
 
It looks like a situation where some plain C would be better,
although I didn't chime in on that discussion, I have an opinion.

You could index the individual UIImages in a quartz2D view,
and save yourself a counter. You could also know there's no overhead
in starting and stopping because you're just resetting an index var,
and of course you'd have access to the current index because you declared it.

Somehow I fell like I'm falling into the clutches of Satan by being too lazy to
do it, even though I can.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.