iPhone: make your default.png sexy

I posted this to my subdomain which is now dormant, but it’s gotten enough page views and comments to make me want to plug the posting here on my active subdomain. So here goes:

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.

Related Posts Plugin for WordPress, Blogger...

One thought on “iPhone: make your default.png sexy

  1. Pingback: Tweets that mention iPhone: make your default.png sexy // Imagineric -- Topsy.com

Leave a Reply

Your email address will not be published. Required fields are marked *

+ nine = 16

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>