Friday 24 January 2014

Splash Screen Animation

AppDelegate.h

#import <UIKit/UIKit.h>

@class ViewController;



@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
    UIImageView *splashView;
}

@property (strongnonatomicUIWindow *window;

@property (strongnonatomicViewController *viewController;

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;

@end

AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow allocinitWithFrame:[[UIScreen mainScreenbounds]];
    // Override point for customization after application launch.
    self.viewController = [[ViewController allocinitWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    
    // Make this interesting.
    
    splashView = [[UIImageView allocinitWithFrame:CGRectMake(0,0320480)];
    splashView.image = [UIImage imageNamed:@"Default.png"];
    [self.window addSubview:splashView];
   [self.window bringSubviewToFront:splashView];
    [UIView beginAnimations:@"yourAnim" context:nil];
    [UIView setAnimationDuration:2.0];
   [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.window cache:YES];
   [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
    splashView.alpha = 0.0;
    splashView.frame = CGRectMake(-60, -85440635);
    //[UIView commitAnimations];
    
    return YES;
}

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
    [splashView removeFromSuperview];
}

Type 2:



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow allocinitWithFrame:[[UIScreen mainScreenbounds]];
    // Override point for customization after application launch.
    self.viewController = [[ViewController allocinitWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    
    // Make this interesting.
  
   splashView = [[UIImageView allocinitWithImage:[UIImage imageNamed:@"Default.png"]];
    [splashView sizeToFit];
    
    UIViewController* tmpVC = [UIViewController new];
    [tmpVC.view setFrame:splashView.bounds];
    [tmpVC.view addSubview:splashView];
    
    // just by instantiating a UIWindow, it is automatically added to the app.
    UIWindow *keyWin = [UIApplication sharedApplication].keyWindow;
    UIWindow *hudWindow = [[UIWindow allocinitWithFrame:CGRectMake(0.0f, -20.0f, keyWin.frame.size.width, keyWin.frame.size.height)];
    
    [hudWindow setBackgroundColor:[UIColor clearColor]];
    [hudWindow setRootViewController:tmpVC];
    [hudWindow setAlpha1.0];
    [hudWindow setWindowLevel:UIWindowLevelStatusBar+1];
    [hudWindow setHidden:NO];
    
    UIWindow *_hudWin = hudWindow;
    
    [UIView animateWithDuration:2.0f animations:^{
        [_hudWin setAlpha:0.f];
    } completion:^(BOOL finished) {
        [_hudWin removeFromSuperview];
        
    }];
    
    return YES;
}

No comments:

Post a Comment