Some favorite site feeds aggregated locally: iPhone Development RSS   Adobe Labs RSS   Macrumors RSS

Thursday, July 30, 2009

iPhone: Make your Default.png sexy

Thursday, July 30, 2009   

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.


 Return to the main page

There are currently 5 Comments:

Blogger Chris said...
“Nice, I like it!”
Blogger e.dolecki said...
August 6, 2009 5:08 PM

I'm glad you like it. I hope many more applications take this kind of approach. It's better than fake loaders and the like.”
Anonymous AJ said...
August 8, 2009 2:12 AM

Thats way cool an idea than what the apple suggests. This is supposed to add lot more appeal to the app loading. Surely mess with it this weekend when I am not working!

Thanks for a nice post. I am following you :-)

Anonymous Reba said...
August 12, 2009 10:36 AM
“Now that is sexy :)

The beauty of life, as well as the better kind of user experience, is in the tiny things - thanks for tackling this one...”
Anonymous Anonymous said...
January 24, 2010 6:47 AM
“Hi Eric

I came across your blog and so tried your code, i think it's so nice that i have added it to my app. My initial default.png is an aircraft with test below, using your animation i can make the aircraft appear to take off.

Thanks for the code and idea.”
 Leave a comment