2011-04-26 96 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