iPhone開發實現splash畫面非常簡單,做一張名為Default.png的歡迎界面圖片放在Supporting Files文件夾下替換掉默認的Default.png(為了適配,需要做Default.png、Default@2x.png、Default-568h@2x.png三種尺寸各一張)。 在XXXAppDelegate.m的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions方法中插入以下一行代碼:
// Insert delay of 5 seconds befor the splash screen disappers.
[NSThread sleepForTimeInterval:5.0]; // 其實這一行代碼也可以不加,因為默認情況下歡迎界面的時間只有一秒,加這一句是為了延長
歡迎界面的展示時間到5秒,時間大家可以自己定義。
例如:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]autorelease];
// Insert delay of 5 seconds befor the splash screen disappers.
[NSThread sleepForTimeInterval:5.0];
// Override point for customization after applicationlaunch.
// Add the view controller’s view to the window anddisplay.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
