Think of CAAnimation s as operations applied to the CALayer The animations current state do not change the layers original contents When the original state seems to snap back at the end of the animation it is actually just the animations operation being removed, and the real layers state is being revealed again What you need to do is to register a delegate for your animation, and change the actual self.layer. Contents when the animation ends First: crossFade. Delegate = self Then implement: (void)animationDidStop:(CABasicAnimation *)animation finished:(BOOL)flag { self.layer.
Contents = animation. ToValue; }.
Think of CAAnimations as operations applied to the CALayer. The animations current state do not change the layers original contents. When the original state seems to snap back at the end of the animation it is actually just the animations operation being removed, and the real layers state is being revealed again.
What you need to do is to register a delegate for your animation, and change the actual self.layer. Contents when the animation ends. First: crossFade.
Delegate = self; Then implement: - (void)animationDidStop:(CABasicAnimation *)animation finished:(BOOL)flag { self.layer. Contents = animation. ToValue; }.
Thx for you explanation. I tried this but could not reach animationDidStop. After some researching I found out, that I have to set crossFade.
RemovedOnCompletion = NO; in addition to setting the delegate. This solved my Problem. – Maverick1st Aug 4 at 14:12.
Try this code...It worked for me. -(void)crossFadeImage{ CABasicAnimation *crossFade = CABasicAnimation animationWithKeyPath:@"contents"; crossFade. Duration = 2.0; crossFade.
FromValue = img1. CGImage; crossFade. ToValue = img2.
CGImage; self.background. Layer addAnimation:crossFade forKey:@"animateContents"; self.background. Image = img2; }.
As you might have seen, this is exactly the same code I have posted in my post. This was not working for me so why should your code work in my scenario? – Maverick1st Aug 4 at 14:09.
I want to crossfade between two different UIImages but for a reason I cannot figure out my first UIImage stays when the second one fades in. Here is the sourcecode of my animation (it does a lot more than just crossfading, but the crossfading is my only problem right now). I need all of the three animations listed below to be executed at the same time.
The animation method containing this sourcecode is in a subclass of UIView. This subclass contains several UIImages and one UIImageView where the image to be displayed is contained in. Have I forgotten some essential thing or why is my first image not fading away?
Can it be because it is animated from some other animation at the same time? I hope someone can help me with this.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.