Animated Splash Screen in iPhone

前端 未结 7 1787

I need to implement animated splash screen to the iPhone application. I have seen skype application where same thing is already implemented.

Can anyone has idea how can

7条回答
  •  日久生厌
    2021-02-03 17:03

    Try this

    Appdelegate.h

       @interface AppDelegate : UIResponder  
        {
            UIImageView *splashView;
        }
    
    @property (strong, nonatomic) UIWindow *window;
    
    @property (strong, nonatomic) ViewController *viewController;
    
    - (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;
    

    AppDelegate.m

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
        self.window.rootViewController = self.viewController;
        [self.window makeKeyAndVisible];
    
    // Make this interesting.
        splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
        splashView.image = [UIImage imageNamed:@"Default.png"];
        [self.window addSubview:splashView];
        [self.window bringSubviewToFront:splashView];
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:2.0];
        [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.window cache:YES];
        [UIView setAnimationDelegate:self]; 
        [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
        splashView.alpha = 0.0;
        splashView.frame = CGRectMake(-60, -85, 440, 635);
        [UIView commitAnimations];
    
        return YES;
    }
    
    - (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
        [splashView removeFromSuperview];
    }
    

提交回复
热议问题