【发布时间】:2011-08-07 01:39:58
【问题描述】:
我可以在 iPhone 模拟器和 iPhone 设备上看到启动图像(项目根目录处的 png,大小:320x480 像素)。 然后,我想慢慢透明它(启动图像)。(alpha = 0.0;) 但是我做不到。尽管我尝试了各种方法。
谢谢, 胜美
【问题讨论】:
标签: iphone image ios-simulator
我可以在 iPhone 模拟器和 iPhone 设备上看到启动图像(项目根目录处的 png,大小:320x480 像素)。 然后,我想慢慢透明它(启动图像)。(alpha = 0.0;) 但是我做不到。尽管我尝试了各种方法。
谢谢, 胜美
【问题讨论】:
标签: iphone image ios-simulator
看看 UIView 动画方法。像 animateWithDuartion 这样的方法应该足以满足您的目标。在最简单的实现中,您的淡出动画将如下所示:
[UIView animateWithDuration:1 animations:^(void){self.splashImage.alpha = 0.0f;}];
【讨论】:
当应用启动时,您必须立即通过UIImageView 创建图像的新实例并将其扔到主窗口中。然后,一旦您可以访问该UIView,您就可以使用基本的动画技术将其淡出,例如-animateWithDuration:animations:。
当然,您需要在此下方设置某种类型的视图,以便您可以立即使用主应用的内容。
代码示例:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// PLACE YOUR APP LAUNCH CODE HERE
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default"]];
[self.window addSubview:imageView];
[imageView release];
[UIView animateWithDuration:2.0 animations:^{
imageView.alpha = 0.0;
[imageView removeFromSuperview];
}];
return YES;
}
【讨论】: