How to Add Splash Screen in Your iOS App
//http://www.cocoachina.com/ask/questions/show/57640/%E5%BC%80%E6%9C%BA%E5%8A%A8%E7%94%BB%EF%BC%8C%E6%B8%90%E8%BF%9B%E5%8A%A8%E7%94%BB%E5%8A%A8%E7%94%BB
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; UIImageView *imgview=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; [imgview setImage: [UIImage imageNamed:@"BG_640x960.png"]]; imgview.alpha=1.0; [self.window addSubview:imgview]; UIImageView *gifImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 114, 114)]; NSArray *gifArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"startup_loading_04_114x114.png"], [UIImage imageNamed:@"startup_loading_05_114x114.png"], [UIImage imageNamed:@"startup_loading_06_114x114.png"], [UIImage imageNamed:@"startup_loading_01_114x114.png"], [UIImage imageNamed:@"startup_loading_02_114x114.png"], [UIImage imageNamed:@"startup_loading_03_114x114.png"], nil]; gifImageView.animationImages = gifArray; //动画图片数组 gifImageView.animationDuration = 3.0; //执行一次完整动画所需的时长 gifImageView.animationRepeatCount = 0; //动画重复次数 [gifImageView startAnimating]; gifImageView.center=self.window.center; [self.window addSubview:gifImageView]; [self performSelector:@selector(ViewController) withObject:nil afterDelay:3.0]; return YES; } -(void)ViewController { nav = [[UINavigationController alloc] initWithRootViewController:self.viewController]; [self.window addSubview:nav.view]; [self.window addSubview:tabBarController.view]; self.window.rootViewController = nav; [nav release]; wAVEYNO2ViewController =[ [WAVEYNO2ViewController alloc] initWithNibName:@"WAVEYNO2ViewController" bundle:nil]; [nav pushViewController:wAVEYNO2ViewController animated:YES]; }
最简单方式
iPhone开发实现splash画面非常简单,做一个全屏的欢迎页的图片,把它命名为Default.png,然后放在Xcode工程的Resource里面。 在XXXAppDelegate.m程序中,插入以下代码:
1 |
[ NSThread
sleepForTimeInterval:2.0]; //splash画面就停留2秒后消失 |
三。。。。。。
//delegate里面右个这个函数,只要它没结束,你的等待界面就不会消失。 可以在启动的时候做些动画 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [window addSubview:viewController.view]; [self.window makeKeyAndVisible]; splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)]; splashView.image = [UIImage imageNamed:@"Default.png"]; [self.window addSubview:splashView]; [self.window bringSubviewToFront:splashView]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:2.0]; [UIView setAnimationTransition:UIViewAnimationTransitionNone forView: self.window cache:YES]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)]; splashView.alpha = 0.0; splashView.frame = CGRectMake(-60, -85, 440, 635); [UIView commitAnimations]; return YES; } - (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { [splashView removeFromSuperview]; [splashView release]; }
http://www.xuebuyuan.com/1593101.html
http://www.codeios.com/forum.php?mod=viewthread&tid=594&page=1#pid1391
原文:http://www.cnblogs.com/hl666/p/3668990.html