More iPhone code. I wanted to have the startup logo (Default.png) graphic fade into the first screen after the program starts. This is a much nicer transition than just letting the view switch instantly.
1) Add the new image view to the class.
UIImageView *splashView;
And add this selector:
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;
2) at the very bottom of "applicationDidFinishLaunching" add:
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:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
splashView.alpha = 0.0;
[UIView commitAnimations];
3) Add this selector to cleanup the image and save memory.
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[splashView removeFromSuperview];
[splashView release];
}
4) Awesome bonus bit. Add this below the splashView.alpha = 0.0 line. It adds that extra bit of coolness to the transition.
splashView.frame = CGRectMake(-60, -60, 440, 600);
Wednesday, November 19, 2008
Subscribe to:
Post Comments (Atom)

7 comments:
Is there a way to do this with the image rotated 90 degrees to the right, for an app starting up in landscape?
friggin awesome !!
Pretty Cool, all right! :) Thanks!
Thanks, you help me out loads. :)
I did not know it is that easy :) Thanks!!
Thanks, excellent implementation!
Thank you! Very nice.
Post a Comment