对于所有需要这个的人,我知道有很多......
(在 Xcode 版本 4.2.1 上制作)
So...
在 AppDelegate.h 中添加以下内容:
@property (nonatomic, strong) UIImageView *splashView;
在 AppDelegate.m 中添加以下内容:
课程页面顶部@synthesizesplashView;
进而:
- (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];
}
The [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];
就这样吧:)
希望有帮助。
祝你编程愉快......