iPhone - Showing dynamic splash screens

人盡茶涼 提交于 2019-12-03 09:12:32
Jaspreet Singh

This code may help you to add splash screen by coding

in .h class

UIImageView *myImgView;


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

in .m class

- (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;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!