0

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];
user2320861
  • 1,391
  • 2
  • 11
  • 28

1 Answers1

0

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.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Thanks, it's still doing the blink. – user2320861 Aug 08 '14 at 00:57
  • 1
    Then you're doing something else you're not telling me about, since I can't reproduce the phenomenon 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". I'm guessing that this "fade" is actually because your frame images are not what you think they are, or you are changing the content of the image view or replacing it in some other animation you are not showing, or something. Anyway the phenomenon cannot be reproduced, nor the question answered, based on what you've said. – matt Aug 08 '14 at 01:09
  • Thanks Matt. That was actually very helpful. After I made a new project specifically to explore the animation problem I discovered that I had, deep within a couple method calls responding to the touch, some code animating the alpha value of that layer from 0 to 1 from an earlier effort to create some other effect. It's embarrassing, but that's what happened. Thanks for your help. – user2320861 Aug 08 '14 at 01:30