程序启动的时候,实现Default 图片向四周扩散的动画
原理是作为在程序启动的代码里面生成一个UIImageView, 此view的图片就是程序中的Default.png图片。
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
[self showSplashView];
}
- (void)showSplashView { splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)]; UIImage *image = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Default.png"]]; splashView.image = image; [image release]; [window addSubview:splashView]; [window bringSubviewToFront:splashView]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3]; [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)]; splashView.alpha = 0.0; splashView.frame = CGRectMake(-60, -40, 440, 600); [UIView commitAnimations]; } - (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { [splashView removeFromSuperview]; [splashView release]; } 调用的时候: [self showSplashView];