×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Objective-C
Posted by: Davide
Added: Jul 17, 2012 1:55 PM
Views: 63
Tags: ios splash
Just call the function somewhere in your AppDelegate's -applicationDidFinishLaunching:withOptions: method
  1. - (void)showSplashWithDuration:(CGFloat)duration
  2. {
  3.     // add splash screen subview ...
  4.     UIImage *image          = [UIImage imageNamed:@"Default.png"];
  5.     UIImageView *splash     = [[UIImageView alloc] initWithImage:image];
  6.     splash.frame            = self.window.bounds;
  7.     splash.autoresizingMask = UIViewAutoresizingNone;
  8.     [self.window addSubview:splash];
  9.  
  10.     // block thread, so splash will be displayed for duration ...
  11.     CGFloat fade_duration = 0.5f;
  12.     [NSThread sleepForTimeInterval:duration - fade_duration];
  13.  
  14.     // animate fade out and remove splash from superview ...
  15.     [UIView animateWithDuration:fade_duration animations:^ {
  16.         splash.alpha = 0.0f;
  17.     } completion:^ (BOOL finished) {
  18.         [splash removeFromSuperview];
  19.     }];
  20. }