Question

Im trying to fade several background images in xcode. They are animated but not fading, see code below:

animationgirl.animationImages = [NSArray arrayWithObjects:

                             [UIImage imageNamed:@"girl1.png"],
                             [UIImage imageNamed:@"girl2.png"],
                             [UIImage imageNamed:@"girl3.png"],
                             [UIImage imageNamed:@"girl4.png"],
                             [UIImage imageNamed:@"girl5.png"],
                             [UIImage imageNamed:@"girl6.png"],
                             [UIImage imageNamed:@"girl7.png"],
                             [UIImage imageNamed:@"girl8.png"],
                             [UIImage imageNamed:@"girl9.png"],
                             [UIImage imageNamed:@"girl10.png"],
                             [UIImage imageNamed:@"girl11.png"],
                             [UIImage imageNamed:@"girl12.png"],
                             [UIImage imageNamed:@"girl13.png"],
                             [UIImage imageNamed:@"girl14.png"],nil];

[animationgirl setAnimationRepeatCount:0];
animationgirl.animationDuration = 1.8;
[animationgirl startAnimating];

No correct solution

OTHER TIPS

Setting animationImages does not support an additional fade-in/fade-out effect when transitioning between images.

What you can do is creating a CAKeyframeAnimation and provide it with the array of images you are trying to animate, e.g.:

    NSArray* contents = <NSArray of UIImages>;

    CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
    [animation setCalculationMode:kCAAnimationLinear];
    [animation setDuration:contentsAnimationDuration];
    [animation setRepeatCount:HUGE_VALF];
    [animation setValues:contents];        

    [self.layer addAnimation:animation forKey:@"contents"];

In order to use Core Animation, you have to link the Quartz framework and include the relevant header file.

You could also you a category on CALayer I wrote for this purpose.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top