2011-04-26 95 views
1

我正在創建一個具有選擇主題的應用程序。根據所選主題,我還想更改啓動畫面。如果我不使用「Default.png」並使用圖像視圖或類似圖像來顯示啓動畫面圖像,則最終會在加載過程中顯示黑色視圖。iPhone - 顯示動態啓動畫面

如何根據所選主題顯示動態閃屏。可能嗎?

回答

1

此代碼可以幫助你添加閃屏通過編碼

在.H類

UIImageView *myImgView; 


//---------methods to show and hide splash---------- 
-(void)ShowSplash; 
-(void)hideSplash; 

中的m級

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // Override point for customization after application launch. 
    [self ShowSplash]; 
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease]; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

-(void)ShowSplash 
{ 
    myImgView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)]; 
    myImgView.backgroundColor=[UIColor colorWithRed:0 green:.3 blue:0.5 alpha:1]; 
    myImgView.image=[UIImage imageNamed:@"splashscreen.png"]; 
    [self.window addSubview:myImgView]; 
    [self performSelector:@selector(hideSplash) withObject:nil afterDelay:1]; 
} 

-(void)hideSplash 
{ 
    [UIView beginAnimations:@"flipping view" context:nil]; 
    [UIView setAnimationDuration:1.5]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:myImgView.superview cache:YES]; 
    [myImgView removeFromSuperview]; 
    [UIView commitAnimations]; 
    [myImgView release]; 
    myImgView=nil; 
    self.window.rootViewController = self.viewController; 
} 
+0

謝謝@jaspreet,其真正的工作。 – ravinder521986 2015-02-02 05:02:23