Add some polish to iPhone app start up

First impressions last, and the very first impression your users have of your iPhone application is the start up. First step is to have a nice Default.png, but not many words spilled on that one, it is well covered in Apple’s documentation.

Creating a perfect Default.png is impossible, especially if you have different setup of navigation and tab bars in different parts of your app. And even harder to adjust for the different sizes of the status bar. With the advent of tethering the size of the status bar is even more sure to be random at startup. This adds to a small jerk, or ugly jump of the user interface at start up.

Create a smooth startup

The easiest way to counter this small jerk is to let your user interface fade in. It is pleasing to the eye, and easy to do. So easy that this blog post pretty much ends after a small code block you can cut&paste into any of your projects.

If you create your UI using Interface Builder, or create it in code, you still have an implementation of applicationDidFinishLaunching: that ends like this:

// ...more code...
  [window makeKeyAndVisible];

This is where we will add our own code that will slide in a new view, above the root view, mimicking the Default.png look. This view is then quickly faded out and removed, creating the appearance of fading in our real user interface.

// ...more code...
  UIImage* backImage = [UIImage imageNamed:@"Default.png"];
  UIView* backView = [[UIImageView alloc] initWithImage:backImage];
  backView.frame = window.bounds;
  [window addSubview:backView];
  [UIView beginAnimations:@"CWFadeIn" context:(void*)backView];
  [UIView setAnimationDelegate:self];
  [UIView setAnimationDidStopSelector:
  [UIView setAnimationDuration:0.5f];
  backView.alpha = 0;
  [UIView commitAnimations];
  [window makeKeyAndVisible];

-(void)animationDidStop:(NSString*)animationID finished:(NSNumber*)finished
  UIView* backView = (UIView*)context;
  [backView removeFromSuperview];
  [backView release];

And that is it, instant better first impression.

This Post Has 8 Comments

  1. Dorald

    THANK YOU Fredrik !!

    Thanks a lot for your code. It helped me a lot.

  2. Joe McMahon

    Very nice indeed. I’ll stash this one in my code fragments file.

  3. David G

    Absolutely great – why can’t all tips be as simple to install as this!

  4. Nik

    great tip, thanks!


  5. gil

    thanks – of the several bits of code out there to do this…. this is the easiest to get working!

  6. Bert

    Hello Jayway it’s nice idea! by the way I need help to start my app with iphone power on like some daemon programs. for IOS4 I’ve try many ways but non of it is working for me, can you help? thanks a lot!!

Leave a Reply