How it works:
(Made on Xcode version 4.2.1)
So...
In AppDelegate.h add this:
@property (nonatomic, strong) UIImageView *splashView;
In AppDelegate.m add this:
At the top of the page cours @synthesize splashView;
And then:
- (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] is responsible for how long the splashView will be ahead of the delay time you choose.
You can reposition the indicator by changing nubmers x / y to:
activityIndicator.center = CGPointMake (160, 360);
Finally, under the method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Just add this:
[self performSelector:@selector(splashFade) withObject:nil];
And here you go :) Hope this helps.
Good programming ....
Maor zohar
source share