给iPhone程序添加欢迎界面

以前写了一篇文章:给iPhone程序添加欢迎界面,这种方式固然能达到目的,而且也方便,但是,显得有点突兀。这篇文章采用了另一种方式添加欢迎页面,并采用了动画效果。

 

在AppDelegate.h中添加UIImageView *splashView;以及一个方法声明:

 

- (void) startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;

 

在AppDelegate.m中的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中添加以下代码: 

 

splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:@"Default.png"];
[self.window addSubview:splashView];
[self.window bringSubviewToFront:splashView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.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];

你可能感兴趣的:(ios,iPhone)