How to add animated splash screen in our application

前端 未结 4 1286
说谎
说谎 2020-12-13 22:39

How to add animated splash screen in our application.

4条回答
  •  情深已故
    2020-12-13 23:05

    I do this by creating an array of images because gif is not supported format

    Just add image frames of your movieclip for eg: {Splashbackground1,Splashbackground2,Splashbackground3 are sequence of images}

    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    - (void)viewDidLoad {
        // create the view that will execute our animation for elephant
        CGRect splashscreenmovieclipframe = CGRectMake(0.0f,0.0f,480.0f, 320.0f); //set co-ordinate here i use full screen
        splashscreenmovieclip = [[UIImageView alloc] initWithFrame:splashscreenmovieclipframe];
    
        // load all the frames of our animation
        splashscreenmovieclip.animationImages = [NSArray arrayWithObjects:   
                                        [UIImage imageNamed:@"Splashbackground.png"],
                                                 [UIImage imageNamed:@"Splashbackground1.png"],
                                                 [UIImage imageNamed:@"Splashbackground2.png"],
                                                 [UIImage imageNamed:@"Splashbackground3.png"],
                                                 nil];
    
        // all frames will execute in 1.75 seconds
        splashscreenmovieclip.animationDuration =7;
        // repeat the annimation forever
        splashscreenmovieclip.animationRepeatCount = 0;
        // start animating
        [splashscreenmovieclip startAnimating];
        // add the animation view to the main window
        [self.view addSubview:splashscreenmovieclip];
    
        [NSTimer scheduledTimerWithTimeInterval:7.0f target:self selector:@selector(Gotomainmenuview:) userInfo:nil repeats:NO];
    
        [super viewDidLoad];
    }
    
    
    - (void)Gotomainmenuview:(NSTimer *)theTimer 
    {
        // write your code here for counter update 
        [splashscreenmovieclip removeFromSuperview];
        newclasstojump *mmvc=[[newclasstojump alloc]initWithNibName:@"newclasstojump" bundle:nil];
        [self.view addSubview:mmvc.view];
    }
    

提交回复
热议问题