【发布时间】:2010-03-28 22:14:13
【问题描述】:
我有这段代码应该创建一个没有动画或淡入的启动图像,然后调用代码在延迟后将图像关闭。 SplashViewAnimationNone 可以正常工作并创建全屏图像,但 Fade 代码会淡入图像但随后立即消失。
- (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];
}
【问题讨论】:
标签: iphone objective-c