I've got a UIImageView whose image
property is set to an image which corresponds to the first frame of an animation. At some point, the user performs a touch and the animation starts playing. However, I've noticed a "blink" in the UIImageView when the animation first starts. I discovered that what is happening is that when I call startAnimating
the UIImageView removes the image
in its image property (leaving the background color) so that it can fade in the first frame of the animation BEFORE the animation starts playing.
I do not want it to "fade in" the first frame; the first frame is already there. I don't care if it takes a split second to start playing the animation, but the "fade in" for the first frame is causing the unwanted blink. How can I keep it from "fading in" that first frame?
Thanks,
In viewDidLoad
...
self.animationView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"frame0"],
[UIImage imageNamed:@"frame1"],
[UIImage imageNamed:@"frame2"],
[UIImage imageNamed:@"frame3"],
[UIImage imageNamed:@"frame4"],
[UIImage imageNamed:@"frame5"], (etc..)
nil];
self.animationView.animationDuration = 0.25;
self.animationView.animationRepeatCount = 1;
Later on...
[self.animationView startAnimating];
Don't do that in viewDidLoad
. In viewDidLoad
, give the view a normal image - the first frame image. When you want to start animating, then do what you are doing: assign animationImages
and start animating.
Alternatively, perhaps some other code you aren't telling us about is responsible for this effect. I can't reproduce it at all. When I start an animation whose first frame is the same as the existing image in the image view there is no "fade", so something else may well be going on in your situation.