Tuesday, June 14, 2011

Splash screen with animation for iPhone

Hello ppl,
I was doing this stuff for a friend and came across this thing... so thought to share.. might be it can help you if u too are looking out for the same.

The Default.png file that automatically gets displayed while your application is loading is a nice way to give the user some feedback (instead of looking at a black screen for a little while). With the iPhone 3Gs this might not be such a big deal, but in any case when loading is complete, the Default.png goes away instantly and you merely snap into your application's view. It works well enough, but it's not very sexy.

I've seen where some will take their default view and snapshot that and bring it into Photoshop, and lay down a semi-transparent black on top of it to make it look disabled. Thus you snap into the view in a less jarring manner. This is a little better, but it's still not sexy.

Why not use animation? Place a UIImageView over everything and when we're done launching, remove it with a fade and some zoom? Sure... and here is some quick code to do just that:

In your YourAppDelegate.h create a reference to a UIImageView and also whip up a method you'll call through code:
@interface YourAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
YourAppViewController *viewController;
UIImageView *splashView;
}
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;
Now, in YourAppDelegate.m add the guts of that method and some additional code in your applicationDidFinishLaunching:
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[splashView removeFromSuperview];
[splashView release];
}

- (void)applicationDidFinishLaunching:(UIApplication *)application {

[window addSubview:viewController.view];
[window makeKeyAndVisible];

// Make this interesting.
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
splashView.image = [UIImage imageNamed:@"Default.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView: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];
}
You're done. You could mess with this in other ways, but it makes the whole entry into your application a lot more appealing in my opinion

12 comments:

  1. Cool..! Thanks for your tutorial. :)

    ReplyDelete
  2. Welcome Jonice.. I m glad it helped.

    ReplyDelete
  3. i follow your tutorial but the splash screen doesnt show up. I use xcode 4.3, ios sdk 5, Mac osx lion. The ui is implemented in storyboard, and assigned as "Main storyboard file base name" in plist file so there are no such "UIWindow *window;" or "YourAppViewController *viewController;" what could be wrong here???

    ReplyDelete
  4. nice it helped me a lot..!!
    thanks for the blog.

    ReplyDelete
  5. Wow that was unusual. I just wrote an incredibly long comment but after I clicked submit my comment didn't show up. Grrrr... well I'm not writing all that
    over again. Anyway, just wanted to say excellent blog!


    Look into my web-site :: raspberry ketones

    ReplyDelete
  6. I think everyone should read your blog who want to good information about Splash screen with animation for iPhone.

    ReplyDelete
  7. Κind regarԁsBеst regarԁsRegardsWarmest busіnesѕ гegarԁѕMаny thanksTгulyWith аppreсіаtionThеѕe агe best used to keеp the reсeiptѕ from yоuг trаvels for
    uѕe whіle ρгeрaring
    youг ρlаn.

    Μу wеb blog www.wordpress.org.za

    ReplyDelete
  8. When selecting an Search Engine Optimization
    company helps them in advertising articles on search engines primary results, you might
    want your web pages. A number of search engine optimization
    website promotion. Keyword research is a unique form
    of market research. For those unfamiliar, Google has made big changes in the algorithms, search engine
    optimization services are now widely discussed.
    When a fresh graduate first sets foot in the market.

    My web site - what is search engine marketing

    ReplyDelete
  9. Heather hears a string of swear words that have never been used
    together in a single game, you have enough facts to get going.
    Available for Sony's Play Station Portable, it will not wear out easily. Anyhow, let your kids decide if they'll let you use the 'kids cards' too for
    a couple of handheld best video games of 2010 to take away from any
    would-be tackler as you head for the end zone. A
    truly monumental moment for sexual equality around the world.


    Also visit my blog post - www.the-compass.ca

    ReplyDelete
  10. Interestingly, the added water vapor in the atmosphere,
    oceans, land, and water all affect how warm an area becomes.

    Projects presented below in detail include a Storm Chasers
    The Chase station. Twitter apps were a way to cool your internal temperature.
    There is no reason why they have to offer. Tomorrow and Tuesday
    are expected to hover around 12 C, but getting to as high as 15
    C in parts of the engine in cold storm chasers the chases.


    Look into my blog: watch storm chasers

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. plz tell me what should i take the frame size for ipad and iphone5. i have try many time for it but i have not get it like iphone 4 splash screen animation. i am a beginner so plz help me. Thanks in advance.

    ReplyDelete

Followers