这就是它的工作原理:
(基于 Xcode 4.2.1 版制作)
所以……
在 AppDelegate.h 中添加:
@property (nonatomic, strong) UIImageView *splashView;
在 AppDelegate.m 中添加:
在课程页面顶部@synthesize splashView;
然后:
- (void) splashFade
{
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:2.0];
[UIView setAnimationDelay:2.5];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
splashView.alpha = 0.0;
[UIView commitAnimations];
//Create and add the Activity Indicator to splashView
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityIndicator.alpha = 1.0;
activityIndicator.center = CGPointMake(160, 360);
activityIndicator.hidesWhenStopped = NO;
[splashView addSubview:activityIndicator];
[activityIndicator startAnimating];
}
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
[splashView removeFromSuperview];
}
[UIView setAnimationDelay:2.5] 负责根据您选择的延迟时间,splashView 将在前面多长时间。
你可以通过改变x/y的数值来改变指标的位置:
activityIndicator.center = CGPointMake(160, 360);
最后,在方法下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
只需添加这个:
[self performSelector:@selector(splashFade) withObject:nil];
你去吧:)
希望对您有所帮助。
祝你编程愉快......