Tuesday, 14 June 2011

Animation Effect on your Splash/Welcome Screen on iPhone

In this tutorial, I'll give an example of how to have your own welcome image, and add the fade and zoom effect to it. When the iPhone launches your application, it looks for an image named Default.png in the resources directory. In the following example, Default.png is being replaced by a UIImageView which zooms and then fades away. (Consider abc to be your project name)

1. To abcAppDelegate.h, add the function declaration

- (void) welcomeScreen

2. To abcAppDelegate.m, add the function definition

- (void) welcomeScreen
//Welcome Screen
UIImageView* welcome = [[[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)]autorelease];
welcome.image = [UIImage imageNamed:@"img.png"];
[window addSubview:welcome];
[window bringSubviewToFront:welcome];
//Animation Effects (zoom and fade)
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES];
[UIView setAnimationDelegate:welcome];
[UIView setAnimationDidStopSelector:@selector(removeFromSuperview)];

//set transparency to 0.0
welcome.alpha = 0.0;

//zoom effect
welcome.frame = CGRectMake(-60, -60, 440, 600);
[UIView commitAnimations];


3. Call the method welcomeScreen

From applicationDidFinishLaunching method in abcAppDelegate.m, invoke welcomeScreen.

- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:viewController.view];
[window makeKeyAndVisible];
[NSTimer scheduledTimerWithTimeInterval:1.0/30. target:self selector:@selector(welcomeScreen) userInfo:nil repeats:NO];


And it's a wrap! Cheers!


  1. This comment has been removed by a blog administrator.

  2. This comment has been removed by the author.

  3. I have a TableViewController as my main view. I have placed the code you show, but I get one error:
    At line:
    [_window addSubview:viewController.view];
    I get the error: use of undeclared identifier 'viewController'

    Can you give any clues about this error?

    Thank you very much.

  4. This is not working it was showing error on aading viewcontroller to view