Écran de démarrage animé dans iPhone

J'ai besoin de mettre en place un écran de démarrage animé à l'application iPhone. J'ai vu l'application Skype où la même chose est déjà implémentée.

Quelqu'un peut-il avoir une idée comment puis-je mettre en œuvre la même chose dans mon applicatio

Prenez un UIView et un Imageview dedans. Donnez toutes vos images à ImageView pour animer.

-(void)viewDidLoad { NSArray *arrImage=[NSArray arrayWithObjects: [UIImage imageNamed:@"1.png"], [UIImage imageNamed:@"2.png"], [UIImage imageNamed:@"3.png"], nil]; imgVw.backgroundColor=[UIColor purpleColor]; imgVw.animationImages=arrImage; imgVw.animationDuration=2.5; imgVw.animationRepeatCount=1; [imgVw startAnimating]; [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(animateNext) userInfo:nil repeats:NO]; } 

Cela va vous montrer l'icône de l'application.

Après cela, vous montrerez les controls qui seront cachés par défaut et les animeront de bas en haut.

 -(void)animateNext { lbl.hidden = NO; btn.hidden = NO; txt1.hidden = NO; txt2.hidden = NO; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1.9]; lbl.frame=CGRectMake(lbl.frame.origin.x,lbl.frame.origin.y - 150,lbl.frame.size.width,lbl.frame.size.height); imgVw.frame = CGRectMake(imgVw.frame.origin.x, imgVw.frame.origin.y - 150, imgVw.frame.size.width, imgVw.frame.size.height); txt1.frame = CGRectMake(txt1.frame.origin.x, txt1.frame.origin.y - 150, txt1.frame.size.width, txt1.frame.size.height); txt2.frame = CGRectMake(txt2.frame.origin.x, txt2.frame.origin.y - 150, txt2.frame.size.width, txt2.frame.size.height); btn.frame = CGRectMake(btn.frame.origin.x, btn.frame.origin.y - 150, btn.frame.size.width, btn.frame.size.height); [UIView commitAnimations]; } 

J'espère que cette aide …

Vous pouvez utiliser une séquence d'images, voici le code:

 for(NSInteger i=1;i<=totalImages;i++){ NSSsortingng *strImage = [NSSsortingng ssortingngWithFormat:@"Activity_%d",i]; UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:strImage ofType:@"png"]]; [imageArray addObject:image]; } splashImageView.animationImages = imageArray; splashImageView.animationDuration = 0.8; 

et appelez simplement la méthode startAnimation et endAnimation de UIImageView.

OU

C'est très simple … Je l'avais utilisé pour commencer mon application avec splashView.Hope it vil vous aider …. Dans AppDelegate.m:

application didFinishLaunchingWithOptions:

 UIImage* image=[UIImage imageNamed:@"splash.jpg"]; splashView=[[UIImageView alloc]initWithImage:image]; [window addSubview:splashView]; [window bringSubviewToFront:splashView]; [self performSelector:@selector(removeSplash) withObject:self afterDelay:2]; [window makeKeyAndVisible]; 

Pour supprimer splashView:

 -(void)removeSplash{ [UIView beginAnimations:nil context:nil]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES]; [UIView setAnimationDuration:0.75]; [UIView setAnimationDelegate:self]; [splashView removeFromSuperview]; [UIView commitAnimations]; [window addSubview:viewController.view]; } 

Nous pouvons montrer une image .gif dans webView et il semble parfait!

Prenez une nouvelle class UIViewController nommée SplashView avec XIB , puis ajoutez un UIWebView avec (320,0, 480,0) cadre, statusbar cachée aussi.

Dans SplashView.h

 #import <UIKit/UIKit.h> @interface SplashView : UIViewController @property(nonatomic, retain)IBOutlet UIWebView *webView; @end 

Dans SplashView.m

 - (void)viewDidLoad { [super viewDidLoad]; NSSsortingng *imagePath = [[NSBundle mainBundle] pathForResource: @"animated" ofType: @"gif"]; NSData *data = [NSData dataWithContentsOfFile:imagePath]; [self.webView setUserInteractionEnabled:NO]; [self.webView loadData:data MIMEType:@"image/gif" textEncodingName:nil baseURL:nil]; } 

C'est à propos de la class SplashView . Maintenant, venez à la class de votre appdelegate.

  - (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]; [[UIApplication sharedApplication] setStatusBarHidden:YES]; splashView = [[SplashView alloc]initWithNibName:@"SplashView" bundle:nil]; [self.window addSubview:splashView.view]; [self performSelector:@selector(changeView) withObject:nil afterDelay:3.0]; [self.window makeKeyAndVisible]; return YES; } -(void)changeView { [[UIApplication sharedApplication] setStatusBarHidden:NO]; [splashView.view removeFromSuperview]; [self.window setRootViewController:self.viewController]; } 

Essaye ça

Appdelegate.h

  @interface AppDelegate : UIResponder <UIApplicationDelegate> { UIImageView *splashView; } @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) ViewController *viewController; - (void)startupAnimationDone:(NSSsortingng *)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:(NSSsortingng *)animationID finished:(NSNumber *)finished context:(void *)context { [splashView removeFromSuperview]; } 

vous devez démarrer votre application avec un viewcontroller, avec une uiimageview dedans. Créer une série d'images .png à soumettre à UIImageView vérifier comment animer un tableau d'images dans uiimageview . En outre pour le rejeter une fois l'animation sur vous aurait besoin d'implémenter un protocole qui informera votre premier viewcontroller de votre application pour rejeter l'animation

 - (void) welcomeScreen { //Welcome Screen UIImageView* welcome = [[[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)]autorelease]; welcome.image = [UIImage imageNamed:@"img.png"]; [window addSubview:welcome]; [window bringSubviewToFront:welcome]; //Animation Effects (zoom and fade) [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:2.0]; [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES]; [UIView setAnimationDelegate:welcome]; [UIView setAnimationDidStopSelector:@selector(removeFromSuperview)]; //set transparency to 0.0 welcome.alpha = 0.0; //zoom effect welcome.frame = CGRectMake(-60, -60, 440, 600); [UIView commitAnimations]; } 

oui simple dans la class AppDelegate premier defile imageview comme ci-dessous ..

 @interface AppDelegate : UIResponder { UIImageView *splashView; } 

et dans le file .m …

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; splashView.image = [UIImage imageNamed:@"Default"]; [self.window addSubview:splashView]; [self performSelector:@selector(loadViewIphone) withObject:nil afterDelay:2.0]; } [self.window makeKeyAndVisible]; return YES; } -(void)loadViewIphone { [splashView removeFromSuperview]; self.window.rootViewController = self.tabBarController; [self.window makeKeyAndVisible]; CATransition *animation = [CATransition animation]; [animation setDelegate:self]; [animation setType:kCATransitionFade]; [animation setDuration:0.5]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]]; [[self.window layer] addAnimation:animation forKey:@"transitionViewAnimation"]; } 

J'espère que cela vous aidera ..

🙂