UIImageView Fade-In Dissapears
Posted
by Winder
on Stack Overflow
See other posts from Stack Overflow
or by Winder
Published on 2010-03-28T22:14:13Z
Indexed on
2010/03/28
23:13 UTC
Read the original article
Hit count: 268
iphone
|objective-c
I have this code which should create a splash image with either no animation or a fade in, then call code to dismiss the image out after a delay. The SplashViewAnimationNone
works fine and creates the full screen image, but the Fade code fades the image in but then immediately disappears.
- (void)startSplash {
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubview:self];
splashImage = [[UIImageView alloc] initWithImage:self.image];
if (self.animationIn == SplashViewAnimationNone)
{
[self addSubview:splashImage];
}
else if (self.animationIn == SplashViewAnimationFade)
{
[self addSubview:splashImage];
CABasicAnimation *animSplash = [CABasicAnimation animationWithKeyPath:@"opacity"];
animSplash.duration = self.animationDelay;
animSplash.removedOnCompletion = NO;
animSplash.fillMode = kCAFillModeForwards;
animSplash.fromValue = [NSNumber numberWithFloat:0.0];
animSplash.toValue = [NSNumber numberWithFloat:1.0];
animSplash.delegate = self;
[self.layer addAnimation:animSplash forKey:@"animateOpacity"];
}
// Dismiss after delay.
[self performSelector:@selector(dismissSplash) withObject:self afterDelay:self.delay];
}
© Stack Overflow or respective owner