views:

89

answers:

1

I have a CABasicAnimation that I perform on multiple layers and all it does is move the UIImageView up 10 pixels and then back down. I want this to continue ad infinitum. When the animation finishes I can't figure out how to get it to do it again! I understand theres a animationDidStop method but that doesn't solve my problem because I can't detect the layer that stopped moving.

How would I achieve animating a UIImageView in a constant up and down animation? I tried with [UIImageView beginAnimations] etc... but there isn't a comulative value for those type of animations

A: 
myBasicAnimation.removedOnCompleted = NO;
myBasicAnimation.fillMode = kCAFillModeForwards;
myBasicAnimation.cumulative = YES;

Then set the rest of the properties the way you normal would to create an animation. Set your repeatCount, fromValue, and toValue.

bstahlhood
I don't understand, How does this cause the animation to repeat after completion? I don't want to set the repeatCount to some arbitrary high number, I just want it to repeat after animation...
Parad0x13
@Parad0x13 I can't see where the solution provided sets a repeat count. It just keeps the animation from being removed after it ran once, resulting in it being run indefinitely (or that's my understanding at least)
Thomas Müller
This will keep the animation on the screen, in the last value of the animation, and cumulate the values, however many times you specify. If you want it to repeat forever, just set repeatCount = HUGE_VALF;
bstahlhood
HUGE_VALF is exactly what I'm trying to avoid, doing it that way feels unpoetic, but it will repeat forever so that does work I suppose
Parad0x13
The problem I have is that when the animation goes up and then down I want to change the duration time! Is this possible if I go this route? I have the repeat count Ad-Infinitum however animationDidStop isn't being called anymore so I can't edit values while they are being animated
Parad0x13